Closed Owen-Hw closed 4 years ago
change: I18n._locale ??= locale; I18n._shouldReload = false; final String lang = I18n._locale != null ? I18n._locale.toString() : ""; final String languageCode = I18n._locale != null ? I18n._locale.languageCode : "";
I'm having a similar problem with the new version.
More precisely:
void updateLocale(BuildContext context) {
if (english ?? false)
I18n.locale = Locale('en', 'US');
else
I18n.locale = Localizations.localeOf(context) ?? Locale('en', 'US');
}
in combination with
@override
initState() {
super.initState();
I18n.onLocaleChanged = onLocaleChanged;
}
void onLocaleChanged(Locale _locale) {
if (mounted) setState(() {});
}
doesn't work any more. This can change the device language to English back and forth.
Installing the old version in Visual Studio Code has helped.
pushed a new version; please retry. sorry for the bug
works :) dankeschön!
new version bug ,can't change language. -------------old version-------- @override Future load(Locale _locale) {
I18n._locale ??= _locale;
I18n._shouldReload = false;
final Locale locale = I18n._locale;
final String lang = locale != null ? locale.toString() : "";
final String languageCode = locale != null ? locale.languageCode : "";
……
}
---------new version---------------------
@override
Future load(Locale locale) {
I18n._locale ??= locale;
I18n._shouldReload = false;
final String lang = I18n._locale != null ? locale.toString() : "";
final String languageCode = I18n._locale != null ? locale.languageCode : "";
......
}