Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localeResolutionCallback override MaterialApp Locale #120

Open
EArminjon opened this issue Nov 7, 2019 · 2 comments
Open

localeResolutionCallback override MaterialApp Locale #120

EArminjon opened this issue Nov 7, 2019 · 2 comments

Comments

@EArminjon
Copy link

EArminjon commented Nov 7, 2019

Hello,

I'm facing an issue with the code below :

MaterialApp(
        debugShowCheckedModeBanner: false,
        locale: ui.window.locale, // it is equal to String("fr")
        localizationsDelegates: [
          S.delegate,
        ],
        localeResolutionCallback: S.delegate.resolution(fallback: const Locale('en', '')),
        supportedLocales: S.delegate.supportedLocales,
);

localeResolutionCallback is, as I understand, a callback when no local is found.
The problem is the following : localeResolutionCallback is always call and override locale: ui.window.locale...

Can you help me ?

@EArminjon EArminjon changed the title Flutter_i18n didn't take phone locale as default localeResolutionCallback override MaterialApp Local Nov 7, 2019
@EArminjon EArminjon changed the title localeResolutionCallback override MaterialApp Local localeResolutionCallback override MaterialApp Locale Nov 7, 2019
@jangruenwaldt
Copy link

I had the same issue. A bit pointless to provide internationalization if always the same language is used, isn't it? Using the code below fixes it:

MaterialApp(
        debugShowCheckedModeBanner: false,
        localizationsDelegates: [
          S.delegate, GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate
        ],
localeResolutionCallback:
            S.delegate.resolution(fallback: const Locale('en', null)),
        supportedLocales: S.delegate.supportedLocales,
);

Anyways, I keep getting The getter 'MY_ARB_KEY' was called on null. Receiver: null. Tried calling: MY_ARB_KEY
frequently, turning the entire plugin is pointless.

@jangruenwaldt
Copy link

Nevermind, translating still sporadically does not work. Also, sometimes the mentioned "called on null" error occurs. I can just suggest everyone to never use this plugin. It is still recommended in some blog posts, but we should make people aware of the issues by leaving 1-star reviews on IntelliJ to make the issues more obvious. It is quite a big waste of time to try using this plugin and will save everyone a headache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants