getx
getx copied to clipboard
Unable to prevent deviceLocale from overriding App Locale (Happened on Android)
Describe the bug Due to "didChangeLocales" in root_controller always replace locale from deviceLocale instead of App's locale, I am unable to prevent deviceLocale from overriding my App's Locale. This issue happen is due to GetMaterialApp uses root_controller, hence whenever didChangeLocales is called, "didChangeLocales" in root_controller will be called.
**Reproduction code
example:
@override
void didChangeLocales(List<Locale>? locales) {
Get.asap(() {
final locale = Get.deviceLocale;
if (locale != null) {
Get.updateLocale(locale);
}
});
}
Due to settings in root_controller, everytime when user change the deviceLocale, it will always override the App's locale.
To Reproduce Steps to reproduce the behavior:
- Load the App once, locale is "en_US"
- Go to Android Settings, change device Language
- Go to App, all the String with .tr will be translated even though I did set it to update.
Expected behavior
- Device Locale shouldn't override the App's Locale that was manually set by user.
Screenshots
Flutter Version: 3.0.3
Getx Version: 4.6.5
Describe on which device you found the bug: ex: Android phone
Minimal reproduce code N/A
I faced this problem too. Is there any progress or maybe a workaround how to make this update conditional?