1级
@override
void initState() {
super.initState();
text =DemoLocalizations.of(context).trans('connection');
}
第2类(DemoLocalizations)
Future<bool> load() async {
String data = await rootBundle.loadString('locale/i18n_${locale.languageCode}.json');
Map<String, dynamic> _result = json.decode(data);
this._sentences = new Map();
_result.forEach((String key, dynamic value) {
this._sentences[key] = value.toString();
});
return true;
}
返回
问题是:屏幕加载(oninit)时如何加载自定义字符串(国际化)?