Easy_localization: Sometimes when I update the current locale, a single screen doesn't update.

Created on 8 Aug 2020  路  6Comments  路  Source: aissat/easy_localization

I'm facing an issue: when I'm on my profile screen and update my current locale, sometimes it doesn't update my home screen, that is 2 screens behind this current screen, it still on English ou if I change from English to Portuguese, it happens in the same way.

I'm using this to update the locale:

Locale locale = Locale('pt', 'BR');
context.locale = locale;

Someone already faced it?

That's my config:

main.dart

void main() => runApp(
      EasyLocalization(
        supportedLocales: [
          Locale('en', 'US'),
          Locale('pt', 'BR'),
        ],
        path: 'assets/translations',
        saveLocale: true,
        fallbackLocale: Locale('en', 'US'),
        child: ModularApp(module: AppModule()),
      ),
    );
bug waiting for customer response

Most helpful comment

I'm facing the same issue, my work around is refresh the previous page after update the locale

Example:
Navigator.of(context).pushNamed(NaviConstant.changeLanguage).whenComplete(() => setState(() {}));

In my specific case, my home screen page is inside another screen with BottomNovigation. So to get back on that screen I have to Pop my current screen. I didn't know if I do this .whenComplete(() => setState(() {})); will resolve the problem, but I'll try this workaround. Thank you.

All 6 comments

I'm facing the same issue, my work around is refresh the previous page after update the locale

Example:
Navigator.of(context).pushNamed(NaviConstant.changeLanguage).whenComplete(() => setState(() {}));

I'm facing the same issue, my work around is refresh the previous page after update the locale

Example:
Navigator.of(context).pushNamed(NaviConstant.changeLanguage).whenComplete(() => setState(() {}));

In my specific case, my home screen page is inside another screen with BottomNovigation. So to get back on that screen I have to Pop my current screen. I didn't know if I do this .whenComplete(() => setState(() {})); will resolve the problem, but I'll try this workaround. Thank you.

I'm using MobX, and my workaround for that was put an Observer wrapping the Scaffold on my main screen that has a BottomNavigationBar were all screen came from.

Having the same issue here on Flutter version 1.22.5

After updating the locale and pop to the previous page, the previous page locale is not updated.

hmm... need recheck this bug
@aissat

@Overman775 @alvindrakes @VictorCamargo @alfred-risb hi guys try this https://github.com/aissat/easy_localization/issues/292#issuecomment-742134521

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HugoHeneault picture HugoHeneault  路  3Comments

necipk picture necipk  路  5Comments

Jerrywyx picture Jerrywyx  路  4Comments

EmmanuelMess picture EmmanuelMess  路  7Comments

Xgamefactory picture Xgamefactory  路  4Comments