I am having an issue with Flutter's GetX package when using the Get.changeTheme() method. The method works perfectly fine when running the app in debug mode on the Android emulator. However, after I install the release APK on a physical device or when running the desktop version of the app, the Get.changeTheme() method doesn't seem to have any effect.

This is my button:

IconButton(
  onPressed: () async {
    if (darkMode.value) {
      await localStorageController.setDarkMode(false);
      darkMode.value = false;
    } else {
      await localStorageController.setDarkMode(true);
      darkMode.value = true;
    }
    print(darkMode.value);
    if (darkMode.value) {
      Get.changeTheme(ThemeData.dark());
      print('Dark');
    } else {
      Get.changeTheme(ThemeData.light());
      print('Light');
    }
  },
  icon: const Icon(Icons.dark_mode)
),

Here is my [Flutter doctor]

0

There are 0 best solutions below