Jonny Borges
Committed by GitHub

Merge pull request #1262 from GoldenSoju/master

Fix for darkTheme not getting changed correctly if default value is set in GetMaterialApp
@@ -245,7 +245,7 @@ class GetMaterialApp extends StatelessWidget { @@ -245,7 +245,7 @@ class GetMaterialApp extends StatelessWidget {
245 onGenerateTitle: onGenerateTitle, 245 onGenerateTitle: onGenerateTitle,
246 color: color, 246 color: color,
247 theme: _.theme ?? theme ?? ThemeData.fallback(), 247 theme: _.theme ?? theme ?? ThemeData.fallback(),
248 - darkTheme: darkTheme, 248 + darkTheme: _.darkTheme ?? darkTheme ?? ThemeData.fallback(),
249 themeMode: _.themeMode ?? themeMode, 249 themeMode: _.themeMode ?? themeMode,
250 locale: Get.locale ?? locale, 250 locale: Get.locale ?? locale,
251 localizationsDelegates: localizationsDelegates, 251 localizationsDelegates: localizationsDelegates,
@@ -293,7 +293,7 @@ class GetMaterialApp extends StatelessWidget { @@ -293,7 +293,7 @@ class GetMaterialApp extends StatelessWidget {
293 onGenerateTitle: onGenerateTitle, 293 onGenerateTitle: onGenerateTitle,
294 color: color, 294 color: color,
295 theme: _.theme ?? theme ?? ThemeData.fallback(), 295 theme: _.theme ?? theme ?? ThemeData.fallback(),
296 - darkTheme: darkTheme, 296 + darkTheme: _.darkTheme ?? darkTheme ?? ThemeData.fallback(),
297 themeMode: _.themeMode ?? themeMode, 297 themeMode: _.themeMode ?? themeMode,
298 locale: Get.locale ?? locale, 298 locale: Get.locale ?? locale,
299 localizationsDelegates: localizationsDelegates, 299 localizationsDelegates: localizationsDelegates,
@@ -10,6 +10,7 @@ class GetMaterialController extends GetxController { @@ -10,6 +10,7 @@ class GetMaterialController extends GetxController {
10 bool testMode = false; 10 bool testMode = false;
11 Key? unikey; 11 Key? unikey;
12 ThemeData? theme; 12 ThemeData? theme;
  13 + ThemeData? darkTheme;
13 ThemeMode? themeMode; 14 ThemeMode? themeMode;
14 15
15 bool defaultPopGesture = GetPlatform.isIOS; 16 bool defaultPopGesture = GetPlatform.isIOS;
@@ -36,7 +37,15 @@ class GetMaterialController extends GetxController { @@ -36,7 +37,15 @@ class GetMaterialController extends GetxController {
36 Map<int, GlobalKey<NavigatorState>> keys = {}; 37 Map<int, GlobalKey<NavigatorState>> keys = {};
37 38
38 void setTheme(ThemeData value) { 39 void setTheme(ThemeData value) {
39 - theme = value; 40 + if (darkTheme == null) {
  41 + theme = value;
  42 + } else {
  43 + if (value.brightness == Brightness.light) {
  44 + theme = value;
  45 + } else {
  46 + darkTheme = value;
  47 + }
  48 + }
40 update(); 49 update();
41 } 50 }
42 51