问题描述
是否有useContext()函数示例的示例? 我要使用
AppLocalizations.of(context).someText
在许多钩子小部件中,我不确定是否足以在初始化时将其包装在useEffect函数中。
解决方法
我们可以这样使用。
Widget _getAccountRegister() {
final context = useContext();
return Container(
margin: const EdgeInsets.all(10),child: FlatButton(
padding: const EdgeInsets.all(10),onPressed: () {
NavigationUtils.push(context,routeRegister);
},child: Text(Localization.of(context).signIn),),);
}