Closed liudonghua123 closed 4 years ago
Finally, I modified the following code to fix this.
change changeLocale
async
, and in its implementation await delegate.changeLocale
.
void changeLocale(BuildContext context, String localeCode) async
{
if (localeCode != null)
{
await LocalizedApp.of(context).delegate.changeLocale(localeFromString(localeCode));
LocalizationProvider.of(context).state.onLocaleChanged();
}
}
And before dispatch local action, await changeLocale finish.
await changeLocale(
context, '${locale.languageCode}_${locale.countryCode}');
StoreProvider.of<AppState>(context)
.dispatch(LocaleAction(locale));
not work with me
I have a page which contains some bottom navigationbar item and in one page, I set the locale and the strings of current page changed except the appbar title and bottom navigationbar items. I have to click any of the navigationbar item, then it changed. I simplify the code and make a demo on https://github.com/liudonghua123/redux_thunk_example/tree/flutter_translate.
It seems the same as using another translate package (easy_localization, https://github.com/aissat/easy_localization/issues/108).