Get.changeTheme does not work on real Device

Viewed 191

I'm trying to change theme dynamically using GetX library., it works perfectly on iOS simulator, but it does not work on real device.

I'm using this code:

Get.changeTheme(AppThemes.darkTheme);

darkTheme is the custom theme I want to switch to.

1 Answers

I resolved GetX dynamic change theme issue by referencing ThemeMode as per code below instead of the GetX code sample using ThemeData.

In my case this fixed issue where the default device system dark mode would not dynamically update to my ThemeData.light mode.

          //Get.changeTheme(Get.isDarkMode ? ThemeData.light() : ThemeData.dark()); //Code from GetX change theme documentation did not work

            Get.changeThemeMode(Get.isDarkMode ? ThemeMode.light : ThemeMode.dark); //Modified successfully by referencing ThemeMode
           setState(() {
           });
Related