getx icon indicating copy to clipboard operation
getx copied to clipboard

Unable to prevent deviceLocale from overriding App Locale (Happened on Android)

Open shungz89 opened this issue 2 years ago • 1 comments

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:

  1. Load the App once, locale is "en_US"
  2. Go to Android Settings, change device Language
  3. Go to App, all the String with .tr will be translated even though I did set it to update.

Expected behavior

  1. Device Locale shouldn't override the App's Locale that was manually set by user.

Screenshots Screenshot 2022-06-28 at 7 41 14 PM Screenshot 2022-06-28 at 7 46 26 PM

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

shungz89 avatar Jun 28 '22 11:06 shungz89

I faced this problem too. Is there any progress or maybe a workaround how to make this update conditional?

sevoster avatar Dec 22 '23 12:12 sevoster