-
Notifications
You must be signed in to change notification settings - Fork 119
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
Add an option to automatically sync the current locale with the system locale #21
Comments
Can you detect the language change in |
There are some issues preventing this from working currently but yes, I think this will be the way to go. |
Thanks for the great package, we may be using it in our app. Is this enhancement still planned? |
@bratan Can you elaborate on why the |
@kuhnroyal - Because of some iOS issues where different values for the current/selected locale are returned depending on the environment (debug/release) and device type simulator/real device. So by using flutter_device_locale the real locale is always used regardless of the environment. More info: |
@bratan Thanks, Right I now remember this issue. I though this is solved by adding the correct plist entries tho. |
@bratan what about doing this final currentLocale = WidgetsBinding.instance.window.locale;
final locale = currentLocale != null && currentLocale.countryCode != null
? currentLocale
: Localizations.localeOf(context); to avoid using |
Hi @bratan is there any update on this issue? Thanks. |
Hi, there is no update currently as I`m quite busy these days, probably in the near future. |
If anyone wants to implement this themselves, you can use a WidgetsBindingObserver and override didChangeLocales(). Do this with a StatefulWidget below LocalizedApp and above MaterialApp. When a system locale change is detected, you can do something like this:
In my case, I'm restarting the app natively for Android, due to problems trying to force-rebuild the entire widget tree. I'm using the restart_app plugin to do that. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Add an option to automatically sync the current locale with the system locale.
So when the system locale is changed, the current/app locale will be reloaded as well (if supported).
Reference: #20
The text was updated successfully, but these errors were encountered: