/
theme_controller.dart
2261 lines (2089 loc) · 94.2 KB
/
theme_controller.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import 'package:flex_color_scheme/flex_color_scheme.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../const/store.dart';
import '../services/theme_service.dart';
/// Enum to indicate which palette we are using.
///
/// Used to show which TonalPalette a hovered color belongs to.
/// Tucking this ChangeNotifier into the ThemeController is not really kosher
/// it should be in its own Provider/Riverpod or Inherited widget.
///
enum TonalPalettes {
primary,
secondary,
tertiary,
error,
neutral,
neutralVariant,
}
/// The ThemeController is used by many Widgets that users can interact with.
///
/// Widgets can read user theme settings, set user theme settings and listen
/// to user's theme changes.
///
/// The controller glues data Services to Flutter Widgets. The ThemeController
/// uses the ThemeService to save and load theme settings.
///
/// This setup on purpose demonstrates persisting each theme setting value
/// as its own string key and value pair. With this amount of values,
/// bundling them all up in a data class and persisting them all as one big
/// serialized JSON string, with just one settings key, would be more
/// convenient. On the other hand, this is probably more file resource
/// efficient and gives us faster saves of persisted slider values, that can
/// be dragged quickly in the UI. Writing this setup for this many properties is
/// a bit tedious, even if it is simple and very mechanical.
///
/// Normally you would probably not have this many settings properties you
/// want to persist locally (or remotely), in that case this approach is also
/// the simpler and more convenient one. In this particular case though, well
/// maybe not with this amount of props.
//
// ignore:prefer_mixin
class ThemeController with ChangeNotifier {
ThemeController(this._themeService);
// Make the ThemeService private so it cannot be used directly.
final ThemeService _themeService;
/// Load all ThemeController settings from the ThemeService. It may load from
/// app coded defaults, a local database or the internet. The controller only
/// knows it can load all the setting default values from the service.
Future<void> loadAll() async {
//
// GENERAL SETTINGS.
// ThemeMode, use FlexColorScheme and sub-themes, current scheme, view, etc.
_themeMode =
await _themeService.load(Store.keyThemeMode, Store.defaultThemeMode);
_useFlexColorScheme = await _themeService.load(
Store.keyUseFlexColorScheme, Store.defaultUseFlexColorScheme);
_useSubThemes = await _themeService.load(
Store.keyUseSubThemes, Store.defaultUseSubThemes);
_useFlutterDefaults = await _themeService.load(
Store.keyUseFlutterDefaults, Store.defaultUseFlutterDefaults);
_isLargeGridView = await _themeService.load(
Store.keyIsLargeGridView, Store.defaultIsLargeGridView);
_viewIndex =
await _themeService.load(Store.keyViewIndex, Store.defaultViewIndex);
_useTextTheme = await _themeService.load(
Store.keyUseTextTheme, Store.defaultUseTextTheme);
_useAppFont =
await _themeService.load(Store.keyUseAppFont, Store.defaultUseAppFont);
_usedScheme =
await _themeService.load(Store.keyUsedScheme, Store.defaultUsedScheme);
_schemeIndex = await _themeService.load(
Store.keySchemeIndex, Store.defaultSchemeIndex);
_interactionEffects = await _themeService.load(
Store.keyInteractionEffects, Store.defaultInteractionEffects);
_defaultRadius = await _themeService.load(
Store.keyDefaultRadius,
Store.defaultDefaultRadius,
);
_tooltipsMatchBackground = await _themeService.load(
Store.keyTooltipsMatchBackground, Store.defaultTooltipsMatchBackground);
//
// Surface and blend SETTINGS.
_surfaceModeLight = await _themeService.load(
Store.keySurfaceModeLight, Store.defaultSurfaceModeLight);
_surfaceModeDark = await _themeService.load(
Store.keySurfaceModeDark, Store.defaultSurfaceModeDark);
_blendLevel =
await _themeService.load(Store.keyBlendLevel, Store.defaultBlendLevel);
_blendLevelDark = await _themeService.load(
Store.keyBlendLevelDark, Store.defaultBlendLevelDark);
_blendOnLevel = await _themeService.load(
Store.keyOnBlendLevel, Store.defaultBlendOnLevel);
_blendOnLevelDark = await _themeService.load(
Store.keyBlendOnLevelDark, Store.defaultBlendOnLevelDark);
_usedColors =
await _themeService.load(Store.keyUsedColors, Store.defaultUsedColors);
_swapLightColors = await _themeService.load(
Store.keySwapLightColors, Store.defaultSwapLightColors);
_swapDarkColors = await _themeService.load(
Store.keySwapDarkColors, Store.defaultSwapDarkColors);
_lightIsWhite = await _themeService.load(
Store.keyLightIsWhite, Store.defaultLightIsWhite);
_darkIsTrueBlack = await _themeService.load(
Store.keyDarkIsTrueBlack, Store.defaultDarkIsTrueBlack);
_useDarkColorsForSeed = await _themeService.load(
Store.keyUseDarkColorsForSeed, Store.defaultUseDarkColorsForSeed);
_useToDarkMethod = await _themeService.load(
Store.keyUseToDarkMethod, Store.defaultUseToDarkMethod);
_toDarkSwapPrimaryAndContainer = await _themeService.load(
Store.keyToDarkSwapPrimaryAndContainer,
Store.defaultToDarkSwapPrimaryAndContainer);
_darkMethodLevel = await _themeService.load(
Store.keyDarkMethodLevel, Store.defaultDarkMethodLevel);
_blendLightOnColors = await _themeService.load(
Store.keyBlendLightOnColors, Store.defaultBlendLightOnColors);
_blendDarkOnColors = await _themeService.load(
Store.keyBlendDarkOnColors, Store.defaultBlendDarkOnColors);
_blendLightTextTheme = await _themeService.load(
Store.keyBlendLightTextTheme, Store.defaultBlendLightTextTheme);
_blendDarkTextTheme = await _themeService.load(
Store.keyBlendDarkTextTheme, Store.defaultBlendDarkTextTheme);
//
// Material 3 and Seed ColorScheme SETTINGS.
_useMaterial3 = await _themeService.load(
Store.keyUseMaterial3, Store.defaultUseMaterial3);
_useKeyColors = await _themeService.load(
Store.keyUseKeyColors, Store.defaultUseKeyColors);
_useSecondary = await _themeService.load(
Store.keyUseSecondary, Store.defaultUseSecondary);
_useTertiary = await _themeService.load(
Store.keyUseTertiary, Store.defaultUseTertiary);
_keepPrimary = await _themeService.load(
Store.keyKeepPrimary, Store.defaultKeepPrimary);
_keepSecondary = await _themeService.load(
Store.keyKeepSecondary, Store.defaultKeepSecondary);
_keepTertiary = await _themeService.load(
Store.keyKeepTertiary, Store.defaultKeepTertiary);
_keepPrimaryContainer = await _themeService.load(
Store.keyKeepPrimaryContainer, Store.defaultKeepPrimaryContainer);
_keepSecondaryContainer = await _themeService.load(
Store.keyKeepSecondaryContainer, Store.defaultKeepSecondaryContainer);
_keepTertiaryContainer = await _themeService.load(
Store.keyKeepTertiaryContainer, Store.defaultKeepTertiaryContainer);
_keepDarkPrimary = await _themeService.load(
Store.keyKeepDarkPrimary, Store.defaultKeepDarkPrimary);
_keepDarkSecondary = await _themeService.load(
Store.keyKeepDarkSecondary, Store.defaultKeepDarkSecondary);
_keepDarkTertiary = await _themeService.load(
Store.keyKeepDarkTertiary, Store.defaultKeepDarkTertiary);
_keepDarkPrimaryContainer = await _themeService.load(
Store.keyKeepDarkPrimaryContainer,
Store.defaultKeepDarkPrimaryContainer);
_keepDarkSecondaryContainer = await _themeService.load(
Store.keyKeepDarkSecondaryContainer,
Store.defaultKeepDarkSecondaryContainer);
_keepDarkTertiaryContainer = await _themeService.load(
Store.keyKeepDarkTertiaryContainer,
Store.defaultKeepDarkTertiaryContainer);
_usedFlexToneSetup = await _themeService.load(
Store.keyUsedFlexToneSetup, Store.defaultUsedFlexToneSetup);
_useM3ErrorColors = await _themeService.load(
Store.keyUseM3ErrorColors, Store.defaultUseM3ErrorColors);
//
// InputDecorator SETTINGS.
_inputDecoratorSchemeColorLight = await _themeService.load(
Store.keyInputDecoratorSchemeColorLight,
Store.defaultInputDecoratorSchemeColorLight);
_inputDecoratorSchemeColorDark = await _themeService.load(
Store.keyInputDecoratorSchemeColorDark,
Store.defaultInputDecoratorSchemeColorDark);
_inputDecoratorIsFilled = await _themeService.load(
Store.keyInputDecoratorIsFilled, Store.defaultInputDecoratorIsFilled);
_inputDecoratorBorderType = await _themeService.load(
Store.keyInputDecoratorBorderType,
Store.defaultInputDecoratorBorderType);
_inputDecoratorBorderRadius = await _themeService.load(
Store.keyInputDecoratorBorderRadius,
Store.defaultInputDecoratorBorderRadius);
_inputDecoratorUnfocusedHasBorder = await _themeService.load(
Store.keyInputDecoratorUnfocusedHasBorder,
Store.defaultInputDecoratorUnfocusedHasBorder);
_inputDecoratorUnfocusedBorderIsColored = await _themeService.load(
Store.keyInputDecoratorUnfocusedBorderIsColored,
Store.defaultInputDecoratorUnfocusedBorderIsColored);
//
// AppBar SETTINGS.
_appBarStyleLight = await _themeService.load(
Store.keyAppBarStyleLight, Store.defaultAppBarStyleLight);
_appBarStyleDark = await _themeService.load(
Store.keyAppBarStyleDark, Store.defaultAppBarStyleDark);
_appBarOpacityLight = await _themeService.load(
Store.keyAppBarOpacityLight, Store.defaultAppBarOpacityLight);
_appBarOpacityDark = await _themeService.load(
Store.keyAppBarOpacityDark, Store.defaultAppBarOpacityDark);
_appBarElevationLight = await _themeService.load(
Store.keyAppBarElevationLight, Store.defaultAppBarElevationLight);
_appBarElevationDark = await _themeService.load(
Store.keyAppBarElevationDark, Store.defaultAppBarElevationDark);
_transparentStatusBar = await _themeService.load(
Store.keyTransparentStatusBar, Store.defaultTransparentStatusBar);
_appBarBackgroundSchemeColorLight = await _themeService.load(
Store.keyAppBarBackgroundSchemeColorLight,
Store.defaultAppBarBackgroundSchemeColorLight);
_appBarBackgroundSchemeColorDark = await _themeService.load(
Store.keyAppBarBackgroundSchemeColorDark,
Store.defaultAppBarBackgroundSchemeColorDark);
//
// TabBar SETTINGS.
_tabBarStyle = await _themeService.load(
Store.keyTabBarStyle, Store.defaultTabBarStyle);
_tabBarIndicatorLight = await _themeService.load(
Store.keyTabBarIndicatorLight, Store.defaultTabBarIndicatorLight);
_tabBarIndicatorDark = await _themeService.load(
Store.keyTabBarIndicatorDark, Store.defaultTabBarIndicatorDark);
_tabBarItemSchemeColorLight = await _themeService.load(
Store.keyTabBarItemSchemeColorLight,
Store.defaultTabBarItemSchemeColorLight);
_tabBarItemSchemeColorDark = await _themeService.load(
Store.keyTabBarItemSchemeColorDark,
Store.defaultTabBarItemSchemeColorDark);
//
// BottomSheet SETTINGS.
_bottomSheetBorderRadius = await _themeService.load(
Store.keyBottomSheetBorderRadius, Store.defaultBottomSheetBorderRadius);
//
// Android System Navigator bar SETTINGS.
_sysNavBarStyle = await _themeService.load(
Store.keySysNavBarStyle, Store.defaultSysNavBarStyle);
_sysNavBarOpacity = await _themeService.load(
Store.keySysNavBarOpacity, Store.defaultSysBarOpacity);
_useSysNavDivider = await _themeService.load(
Store.keyUseSysNavDivider, Store.defaultUseSysNavDivider);
//
// BottomNavigationBar SETTINGS.
_bottomNavBarBackgroundSchemeColor = await _themeService.load(
Store.keyBottomNavBarBackgroundSchemeColor,
Store.defaultBottomNavBarBackgroundSchemeColor);
_bottomNavigationBarOpacity = await _themeService.load(
Store.keyBottomNavigationBarOpacity,
Store.defaultBottomNavigationBarOpacity);
_bottomNavigationBarElevation = await _themeService.load(
Store.keyBottomNavigationBarElevation,
Store.defaultBottomNavigationBarElevation);
_bottomNavBarSelectedSchemeColor = await _themeService.load(
Store.keyBottomNavBarSelectedItemSchemeColor,
Store.defaultBottomNavBarSelectedItemSchemeColor);
_bottomNavBarUnselectedSchemeColor = await _themeService.load(
Store.keyBottomNavBarUnselectedSchemeColor,
Store.defaultBottomNavBarUnselectedSchemeColor);
_bottomNavBarMuteUnselected = await _themeService.load(
Store.keyBottomNavBarMuteUnselected,
Store.defaultBottomNavBarMuteUnselected);
_bottomNavShowSelectedLabels = await _themeService.load(
Store.keyBottomNavShowSelectedLabels,
Store.defaultBottomNavShowSelectedLabels);
_bottomNavShowUnselectedLabels = await _themeService.load(
Store.keyBottomNavShowUnselectedLabels,
Store.defaultBottomNavShowUnselectedLabels);
//
// NavigationBar SETTINGS.
_navBarBackgroundSchemeColor = await _themeService.load(
Store.keyNavBarBackgroundSchemeColor,
Store.defaultNavBarBackgroundSchemeColor);
_navBarOpacity = await _themeService.load(
Store.keyNavBarOpacity, Store.defaultNavBarOpacity);
_navBarHeight = await _themeService.load(
Store.keyNavBarHeight, Store.defaultNavBarHeight);
_navBarSelectedSchemeColor = await _themeService.load(
Store.keyNavBarSelectedItemSchemeColor,
Store.defaultNavBarSelectedItemSchemeColor);
_navBarUnselectedSchemeColor = await _themeService.load(
Store.keyNavBarUnselectedSchemeColor,
Store.defaultNavBarUnselectedSchemeColor);
_navBarMuteUnselected = await _themeService.load(
Store.keyNavBarMuteUnselected, Store.defaultNavBarMuteUnselected);
_navBarIndicatorSchemeColor = await _themeService.load(
Store.keyNavBarIndicatorSchemeColor,
Store.defaultNavBarIndicatorSchemeColor);
_navBarIndicatorOpacity = await _themeService.load(
Store.keyNavBarIndicatorOpacity, Store.defaultNavBarIndicatorOpacity);
_navBarLabelBehavior = await _themeService.load(
Store.keyNavBarLabelBehavior, Store.defaultNavBarLabelBehavior);
//
// NavigationRail SETTINGS.
_navRailBackgroundSchemeColor = await _themeService.load(
Store.keyNavRailBackgroundSchemeColor,
Store.defaultNavRailBackgroundSchemeColor);
_navRailOpacity = await _themeService.load(
Store.keyNavRailOpacity, Store.defaultNavRailOpacity);
_navigationRailElevation = await _themeService.load(
Store.keyNavigationRailElevation, Store.defaultNavigationRailElevation);
_navRailSelectedSchemeColor = await _themeService.load(
Store.keyNavRailSelectedItemSchemeColor,
Store.defaultNavRailSelectedItemSchemeColor);
_navRailUnselectedSchemeColor = await _themeService.load(
Store.keyNavRailUnselectedSchemeColor,
Store.defaultNavRailUnselectedSchemeColor);
_navRailMuteUnselected = await _themeService.load(
Store.keyNavRailMuteUnselected, Store.defaultNavRailMuteUnselected);
_navRailLabelType = await _themeService.load(
Store.keyNavRailLabelType, Store.defaultNavRailLabelType);
_navRailUseIndicator = await _themeService.load(
Store.keyNavRailUseIndicator, Store.defaultNavRailUseIndicator);
_navRailIndicatorSchemeColor = await _themeService.load(
Store.keyNavRailIndicatorSchemeColor,
Store.defaultNavRailIndicatorSchemeColor);
_navRailIndicatorOpacity = await _themeService.load(
Store.keyNavRailIndicatorOpacity, Store.defaultNavRailIndicatorOpacity);
//
// Button SETTINGS.
_textButtonSchemeColor = await _themeService.load(
Store.keyTextButtonSchemeColor, Store.defaultTextButtonSchemeColor);
_textButtonBorderRadius = await _themeService.load(
Store.keyTextButtonBorderRadius, Store.defaultTextButtonBorderRadius);
_elevatedButtonSchemeColor = await _themeService.load(
Store.keyElevatedButtonSchemeColor,
Store.defaultElevatedButtonSchemeColor);
_elevatedButtonBorderRadius = await _themeService.load(
Store.keyElevatedButtonBorderRadius,
Store.defaultElevatedButtonBorderRadius);
_outlinedButtonSchemeColor = await _themeService.load(
Store.keyOutlinedButtonSchemeColor,
Store.defaultOutlinedButtonSchemeColor);
_outlinedButtonBorderRadius = await _themeService.load(
Store.keyOutlinedButtonBorderRadius,
Store.defaultOutlinedButtonBorderRadius);
_toggleButtonsSchemeColor = await _themeService.load(
Store.keyToggleButtonsSchemeColor,
Store.defaultToggleButtonsSchemeColor);
_toggleButtonsBorderRadius = await _themeService.load(
Store.keyToggleButtonsBorderRadius,
Store.defaultToggleButtonsBorderRadius);
//
// Toggleable SETTINGS.
_unselectedToggleIsColored = await _themeService.load(
Store.keyUnselectedToggleIsColored,
Store.defaultUnselectedToggleIsColored);
_switchSchemeColor = await _themeService.load(
Store.keySwitchSchemeColor, Store.defaultSwitchSchemeColor);
_checkboxSchemeColor = await _themeService.load(
Store.keyCheckboxSchemeColor, Store.defaultCheckboxSchemeColor);
_radioSchemeColor = await _themeService.load(
Store.keyRadioSchemeColor, Store.defaultRadioSchemeColor);
//
// Fab, Chip, SnackBar, Popup, Card nad Dialog SETTINGS.
_fabUseShape = await _themeService.load(
Store.keyFabUseShape, Store.defaultFabUseShape);
_fabBorderRadius = await _themeService.load(
Store.keyFabBorderRadius, Store.defaultFabBorderRadius);
_fabSchemeColor = await _themeService.load(
Store.keyFabSchemeColor, Store.defaultFabSchemeColor);
_chipSchemeColor = await _themeService.load(
Store.keyChipSchemeColor, Store.defaultChipSchemeColor);
_chipBorderRadius = await _themeService.load(
Store.keyChipBorderRadius, Store.defaultChipBorderRadius);
_snackBarSchemeColor = await _themeService.load(
Store.keySnackBarSchemeColor, Store.defaultSnackBarSchemeColor);
_popupMenuOpacity = await _themeService.load(
Store.keyPopupMenuOpacity, Store.defaultPopupMenuOpacity);
_popupMenuBorderRadius = await _themeService.load(
Store.keyPopupMenuBorderRadius, Store.defaultPopupMenuBorderRadius);
_cardBorderRadius = await _themeService.load(
Store.keyCardBorderRadius, Store.defaultCardBorderRadius);
_dialogBackgroundSchemeColor = await _themeService.load(
Store.keyDialogBackgroundSchemeColor,
Store.defaultDialogBackgroundSchemeColor);
_dialogBorderRadius = await _themeService.load(
Store.keyDialogBorderRadius, Store.defaultDialogBorderRadius);
//
// Custom surface tint color SETTINGS.
_surfaceTintLight = await _themeService.load(
Store.keySurfaceTintLight, Store.defaultSurfaceTintLight);
_surfaceTintDark = await _themeService.load(
Store.keySurfaceTintDark, Store.defaultSurfaceTintDark);
//
// Custom color SETTINGS.
_primaryLight = await _themeService.load(
Store.keyPrimaryLight, Store.defaultPrimaryLight);
_primaryContainerLight = await _themeService.load(
Store.keyPrimaryContainerLight, Store.defaultPrimaryContainerLight);
_secondaryLight = await _themeService.load(
Store.keySecondaryLight, Store.defaultSecondaryLight);
_secondaryContainerLight = await _themeService.load(
Store.keySecondaryContainerLight, Store.defaultSecondaryContainerLight);
_tertiaryLight = await _themeService.load(
Store.keyTertiaryLight, Store.defaultTertiaryLight);
_tertiaryContainerLight = await _themeService.load(
Store.keyTertiaryContainerLight, Store.defaultTertiaryContainerLight);
_primaryDark = await _themeService.load(
Store.keyPrimaryDark, Store.defaultPrimaryDark);
_primaryContainerDark = await _themeService.load(
Store.keyPrimaryContainerDark, Store.defaultPrimaryContainerDark);
_secondaryDark = await _themeService.load(
Store.keySecondaryDark, Store.defaultSecondaryDark);
_secondaryContainerDark = await _themeService.load(
Store.keySecondaryContainerDark, Store.defaultSecondaryContainerDark);
_tertiaryDark = await _themeService.load(
Store.keyTertiaryDark, Store.defaultTertiaryDark);
_tertiaryContainerDark = await _themeService.load(
Store.keyTertiaryContainerDark, Store.defaultTertiaryContainerDark);
// Not persisted, locally controlled popup selection for ThemeService,
// resets to actual used platform when settings are reset or app loaded.
_platform = defaultTargetPlatform;
notifyListeners();
}
/// Reset all values to default values and save as current settings.
///
/// Calls setters with notify = false, and calls notifyListeners once
/// after all values have been reset and persisted.
///
/// The reset to default actually, sets and persist all property values that
/// deviates from its defined default value. Only values that actually
/// deviate from their default value are changed. The property setters manage
/// this. They are all set with no notification and notifyListeners() is
/// only called once, after all updates have been made.
///
/// Does not reset the custom colors to their default, only theme settings.
/// We keep the custom colors at their specified values even if theme settings
/// are reset. There is a separate function to reset the custom colors.
Future<void> resetAllToDefaults() async {
//
// GENERAL SETTINGS.
// ThemeMode, use FlexColorScheme and sub-themes, current scheme, view, etc.
await setThemeMode(Store.defaultThemeMode, false);
await setUseFlexColorScheme(Store.defaultUseFlexColorScheme, false);
await setUseSubThemes(Store.defaultUseSubThemes, false);
await setUseFlutterDefaults(Store.defaultUseFlutterDefaults, false);
// The IsLargeGridView and ViewIndex settings are never reset to default in
// a reset, we always keep the current screen and panel on page/panel view.
await setUseTextTheme(Store.defaultUseTextTheme, false);
await setUseAppFont(Store.defaultUseAppFont, false);
await setUsedScheme(Store.defaultUsedScheme, false);
await setSchemeIndex(Store.defaultSchemeIndex, false);
await setInteractionEffects(Store.defaultInteractionEffects, false);
await setDefaultRadius(Store.defaultDefaultRadius, false);
await setTooltipsMatchBackground(
Store.defaultTooltipsMatchBackground, false);
//
// Surface and blend SETTINGS.
await setSurfaceModeLight(Store.defaultSurfaceModeLight, false);
await setSurfaceModeDark(Store.defaultSurfaceModeDark, false);
await setBlendLevel(Store.defaultBlendLevel, false);
await setBlendLevelDark(Store.defaultBlendLevelDark, false);
await setBlendOnLevel(Store.defaultBlendOnLevel, false);
await setBlendOnLevelDark(Store.defaultBlendOnLevelDark, false);
await setUsedColors(Store.defaultUsedColors, false);
await setSwapLightColors(Store.defaultSwapLightColors, false);
await setSwapDarkColors(Store.defaultSwapDarkColors, false);
await setLightIsWhite(Store.defaultLightIsWhite, false);
await setDarkIsTrueBlack(Store.defaultDarkIsTrueBlack, false);
await setUseDarkColorsForSeed(Store.defaultUseDarkColorsForSeed, false);
await setUseToDarkMethod(Store.defaultUseToDarkMethod, false);
await setToDarkSwapPrimaryAndContainer(
Store.defaultToDarkSwapPrimaryAndContainer, false);
await setDarkMethodLevel(Store.defaultDarkMethodLevel, false);
await setBlendLightOnColors(Store.defaultBlendLightOnColors, false);
await setBlendDarkOnColors(Store.defaultBlendDarkOnColors, false);
await setBlendLightTextTheme(Store.defaultBlendLightTextTheme, false);
await setBlendDarkTextTheme(Store.defaultBlendDarkTextTheme, false);
//
// Material 3 and Seed ColorScheme SETTINGS.
await setUseMaterial3(Store.defaultUseMaterial3, false);
await setUseKeyColors(Store.defaultUseKeyColors, false);
await setUseSecondary(Store.defaultUseSecondary, false);
await setUseTertiary(Store.defaultUseTertiary, false);
await setKeepPrimary(Store.defaultKeepPrimary, false);
await setKeepSecondary(Store.defaultKeepSecondary, false);
await setKeepTertiary(Store.defaultKeepTertiary, false);
await setKeepPrimaryContainer(Store.defaultKeepPrimaryContainer, false);
await setKeepSecondaryContainer(Store.defaultKeepSecondaryContainer, false);
await setKeepTertiaryContainer(Store.defaultKeepTertiaryContainer, false);
await setKeepDarkPrimary(Store.defaultKeepDarkPrimary, false);
await setKeepDarkSecondary(Store.defaultKeepDarkSecondary, false);
await setKeepDarkTertiary(Store.defaultKeepDarkTertiary, false);
await setKeepDarkPrimaryContainer(
Store.defaultKeepDarkPrimaryContainer, false);
await setKeepDarkSecondaryContainer(
Store.defaultKeepDarkSecondaryContainer, false);
await setKeepDarkTertiaryContainer(
Store.defaultKeepDarkTertiaryContainer, false);
await setUsedFlexToneSetup(Store.defaultUsedFlexToneSetup, false);
await setUseM3ErrorColors(Store.defaultUseM3ErrorColors, false);
//
// InputDecorator SETTINGS.
await setInputDecoratorSchemeColorLight(
Store.defaultInputDecoratorSchemeColorLight, false);
await setInputDecoratorSchemeColorDark(
Store.defaultInputDecoratorSchemeColorDark, false);
await setInputDecoratorIsFilled(Store.defaultInputDecoratorIsFilled, false);
await setInputDecoratorBorderType(
Store.defaultInputDecoratorBorderType, false);
await setInputDecoratorBorderRadius(
Store.defaultInputDecoratorBorderRadius, false);
await setInputDecoratorUnfocusedHasBorder(
Store.defaultInputDecoratorUnfocusedHasBorder, false);
await setInputDecoratorUnfocusedBorderIsColored(
Store.defaultInputDecoratorUnfocusedBorderIsColored, false);
//
// AppBar SETTINGS.
await setAppBarStyleLight(Store.defaultAppBarStyleLight, false);
await setAppBarStyleDark(Store.defaultAppBarStyleDark, false);
await setAppBarOpacityLight(Store.defaultAppBarOpacityLight, false);
await setAppBarOpacityDark(Store.defaultAppBarOpacityDark, false);
await setAppBarElevationLight(Store.defaultAppBarElevationLight, false);
await setAppBarElevationDark(Store.defaultAppBarElevationDark, false);
await setTransparentStatusBar(Store.defaultTransparentStatusBar, false);
await setAppBarBackgroundSchemeColorLight(
Store.defaultAppBarBackgroundSchemeColorLight, false);
await setAppBarBackgroundSchemeColorDark(
Store.defaultAppBarBackgroundSchemeColorDark, false);
//
// TabBar SETTINGS.
await setTabBarStyle(Store.defaultTabBarStyle, false);
await setTabBarIndicatorLight(Store.defaultTabBarIndicatorLight, false);
await setTabBarIndicatorDark(Store.defaultTabBarIndicatorDark, false);
await setTabBarItemSchemeColorLight(
Store.defaultTabBarItemSchemeColorLight, false);
await setTabBarItemSchemeColorDark(
Store.defaultTabBarItemSchemeColorDark, false);
//
// BottomSheet SETTINGS.
await setBottomSheetBorderRadius(
Store.defaultBottomSheetBorderRadius, false);
//
// Android System Navigator bar SETTINGS.
await setSysNavBarStyle(Store.defaultSysNavBarStyle, false);
await setSysBarOpacity(Store.defaultSysBarOpacity, false);
await setUseSysNavDivider(Store.defaultUseSysNavDivider, false);
//
// BottomNavigationBar SETTINGS.
await setBottomNavBarBackgroundSchemeColor(
Store.defaultBottomNavBarBackgroundSchemeColor, false);
await setBottomNavigationBarOpacity(
Store.defaultBottomNavigationBarOpacity, false);
await setBottomNavigationBarElevation(
Store.defaultBottomNavigationBarElevation, false);
await setBottomNavBarSelectedSchemeColor(
Store.defaultBottomNavBarSelectedItemSchemeColor, false);
await setBottomNavBarUnselectedSchemeColor(
Store.defaultBottomNavBarUnselectedSchemeColor, false);
await setBottomNavBarMuteUnselected(
Store.defaultBottomNavBarMuteUnselected, false);
await setBottomNavShowSelectedLabels(
Store.defaultBottomNavShowSelectedLabels, false);
await setBottomNavShowUnselectedLabels(
Store.defaultBottomNavShowUnselectedLabels, false);
//
// NavigationBar SETTINGS.
await setNavBarBackgroundSchemeColor(
Store.defaultNavBarBackgroundSchemeColor, false);
await setNavBarOpacity(Store.defaultNavBarOpacity, false);
await setNavBarHeight(Store.defaultNavBarHeight, false);
await setNavBarSelectedSchemeColor(
Store.defaultNavBarSelectedItemSchemeColor, false);
await setNavBarUnselectedSchemeColor(
Store.defaultNavBarUnselectedSchemeColor, false);
await setNavBarMuteUnselected(Store.defaultNavBarMuteUnselected, false);
await setNavBarIndicatorSchemeColor(
Store.defaultNavBarIndicatorSchemeColor, false);
await setNavBarIndicatorOpacity(Store.defaultNavBarIndicatorOpacity, false);
await setNavBarLabelBehavior(Store.defaultNavBarLabelBehavior, false);
//
// NavigationRail SETTINGS.
await setNavRailBackgroundSchemeColor(
Store.defaultNavRailBackgroundSchemeColor, false);
await setNavRailOpacity(Store.defaultNavRailOpacity, false);
await setNavigationRailElevation(
Store.defaultNavigationRailElevation, false);
await setNavRailSelectedSchemeColor(
Store.defaultNavRailSelectedItemSchemeColor, false);
await setNavRailUnselectedSchemeColor(
Store.defaultNavRailUnselectedSchemeColor, false);
await setNavRailMuteUnselected(Store.defaultNavRailMuteUnselected, false);
await setNavRailLabelType(Store.defaultNavRailLabelType, false);
await setNavRailUseIndicator(Store.defaultNavRailUseIndicator, false);
await setNavRailIndicatorSchemeColor(
Store.defaultNavRailIndicatorSchemeColor, false);
await setNavRailIndicatorOpacity(
Store.defaultNavRailIndicatorOpacity, false);
//
// Button SETTINGS.
await setTextButtonSchemeColor(Store.defaultTextButtonSchemeColor, false);
await setTextButtonBorderRadius(Store.defaultTextButtonBorderRadius, false);
await setElevatedButtonSchemeColor(
Store.defaultElevatedButtonSchemeColor, false);
await setElevatedButtonBorderRadius(
Store.defaultElevatedButtonBorderRadius, false);
await setOutlinedButtonSchemeColor(
Store.defaultOutlinedButtonSchemeColor, false);
await setOutlinedButtonBorderRadius(
Store.defaultOutlinedButtonBorderRadius, false);
await setToggleButtonsSchemeColor(
Store.defaultToggleButtonsSchemeColor, false);
await setToggleButtonsBorderRadius(
Store.defaultToggleButtonsBorderRadius, false);
//
// Toggleable SETTINGS.
await setUnselectedToggleIsColored(
Store.defaultUnselectedToggleIsColored, false);
await setSwitchSchemeColor(Store.defaultSwitchSchemeColor, false);
await setCheckboxSchemeColor(Store.defaultCheckboxSchemeColor, false);
await setRadioSchemeColor(Store.defaultRadioSchemeColor, false);
//
// Fab, Chip, SnackBar, Popup, Card nad Dialog SETTINGS.
await setFabUseShape(Store.defaultFabUseShape, false);
await setFabBorderRadius(Store.defaultFabBorderRadius, false);
await setFabSchemeColor(Store.defaultFabSchemeColor, false);
await setChipSchemeColor(Store.defaultChipSchemeColor, false);
await setChipBorderRadius(Store.defaultChipBorderRadius, false);
await setSnackBarSchemeColor(Store.defaultSnackBarSchemeColor, false);
await setPopupMenuOpacity(Store.defaultPopupMenuOpacity, false);
await setPopupMenuBorderRadius(Store.defaultPopupMenuBorderRadius, false);
await setCardBorderRadius(Store.defaultCardBorderRadius, false);
await setDialogBackgroundSchemeColor(
Store.defaultDialogBackgroundSchemeColor, false);
await setDialogBorderRadius(Store.defaultDialogBorderRadius, false);
//
// Surface tint colors.
await setSurfaceTintLight(Store.defaultSurfaceTintLight, false);
await setSurfaceTintDark(Store.defaultSurfaceTintDark, false);
//
// Not persisted, locally controlled popup selection for ThemeService,
// resets to actual used platform when settings are reset or app loaded.
await setPlatform(defaultTargetPlatform, false);
notifyListeners();
}
/// Reset the custom color values to their default values.
///
/// Calls setters with notify = false, and calls notifyListeners once
/// after all values have been reset and persisted.
///
/// The reset to default actually, sets and persist all property values that
/// deviates from its defined default value. Only values that actually
/// deviate from their default value are changed. The property setters manage
/// this. They are all set with not notification and notifyListeners() is
/// only called once, weh all updates have been made.
Future<void> resetCustomColorsToDefaults() async {
await setPrimaryLight(Store.defaultPrimaryLight, false);
await setPrimaryContainerLight(Store.defaultPrimaryContainerLight, false);
await setSecondaryLight(Store.defaultSecondaryLight, false);
await setSecondaryContainerLight(
Store.defaultSecondaryContainerLight, false);
await setTertiaryLight(Store.defaultTertiaryLight, false);
await setTertiaryContainerLight(Store.defaultTertiaryContainerLight, false);
await setPrimaryDark(Store.defaultPrimaryDark, false);
await setPrimaryContainerDark(Store.defaultPrimaryContainerDark, false);
await setSecondaryDark(Store.defaultSecondaryDark, false);
await setSecondaryContainerDark(Store.defaultSecondaryContainerDark, false);
await setTertiaryDark(Store.defaultTertiaryDark, false);
await setTertiaryContainerDark(Store.defaultTertiaryContainerDark, false);
notifyListeners();
}
// GENERAL SETTINGS.
// ThemeMode, use FlexColorScheme and sub-themes, current scheme, view, etc.
// ===========================================================================
// Make all ThemeController properties private so they cannot be used
// directly without also persisting the changes using the ThemeService,
// by making a setter and getter for each property.
// Private value, getter and setter for the ThemeMode
late ThemeMode _themeMode;
// Getter for the current ThemeMode.
ThemeMode get themeMode => _themeMode;
// Set and persist new ThemeMode value.
Future<void> setThemeMode(ThemeMode? value, [bool notify = true]) async {
// No work if null value passed.
if (value == null) return;
// Do not perform any work if new and old value are identical.
if (value == _themeMode) return;
// Otherwise, assign new value to private property.
_themeMode = value;
// Inform all listeners a change has occurred, if notify flag is true.
if (notify) notifyListeners();
// Persist the change to whatever storage is used with the ThemeService.
await _themeService.save(Store.keyThemeMode, value);
}
// Repeat above pattern for all other theme settings. The properties will
// not be further explained, property names correspond to equivalent
// FlexColorScheme properties.
late bool _useFlexColorScheme;
bool get useFlexColorScheme => _useFlexColorScheme;
Future<void> setUseFlexColorScheme(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _useFlexColorScheme) return;
_useFlexColorScheme = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyUseFlexColorScheme, value);
}
late bool _useSubThemes;
bool get useSubThemes => _useSubThemes;
Future<void> setUseSubThemes(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _useSubThemes) return;
_useSubThemes = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyUseSubThemes, value);
}
late bool _useFlutterDefaults;
bool get useFlutterDefaults => _useFlutterDefaults;
Future<void> setUseFlutterDefaults(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _useFlutterDefaults) return;
_useFlutterDefaults = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyUseFlutterDefaults, value);
}
late bool _isLargeGridView;
bool get isLargeGridView => _isLargeGridView;
Future<void> setAdvancedView(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _isLargeGridView) return;
_isLargeGridView = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyIsLargeGridView, value);
}
late int _viewIndex;
int get viewIndex => _viewIndex;
Future<void> setViewIndex(int? value, [bool notify = true]) async {
if (value == null) return;
if (value == _viewIndex) return;
_viewIndex = value;
notifyListeners();
await _themeService.save(Store.keyViewIndex, value);
}
late bool _useTextTheme;
bool get useTextTheme => _useTextTheme;
Future<void> setUseTextTheme(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _useTextTheme) return;
_useTextTheme = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyUseTextTheme, value);
}
late bool _useAppFont;
bool get useAppFont => _useAppFont;
Future<void> setUseAppFont(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _useAppFont) return;
_useAppFont = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyUseAppFont, value);
}
late FlexScheme _usedScheme;
FlexScheme get usedScheme => _usedScheme;
Future<void> setUsedScheme(FlexScheme? value, [bool notify = true]) async {
if (value == null) return;
if (value == _usedScheme) return;
_usedScheme = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyUsedScheme, value);
}
late int _schemeIndex;
int get schemeIndex => _schemeIndex;
Future<void> setSchemeIndex(int? value, [bool notify = true]) async {
if (value == null) return;
if (value == _schemeIndex) return;
_schemeIndex = value;
notifyListeners();
await _themeService.save(Store.keySchemeIndex, value);
}
late bool _interactionEffects;
bool get interactionEffects => _interactionEffects;
Future<void> setInteractionEffects(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _interactionEffects) return;
_interactionEffects = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyInteractionEffects, value);
}
late double? _defaultRadius;
double? get defaultRadius => _defaultRadius;
Future<void> setDefaultRadius(double? value, [bool notify = true]) async {
if (value == _defaultRadius) return;
_defaultRadius = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyDefaultRadius, value);
}
late bool _tooltipsMatchBackground;
bool get tooltipsMatchBackground => _tooltipsMatchBackground;
Future<void> setTooltipsMatchBackground(bool? value,
[bool notify = true]) async {
if (value == null) return;
if (value == _tooltipsMatchBackground) return;
_tooltipsMatchBackground = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyTooltipsMatchBackground, value);
}
// Surface and blend SETTINGS.
// ===========================================================================
late FlexSurfaceMode _surfaceModeLight;
FlexSurfaceMode get surfaceModeLight => _surfaceModeLight;
Future<void> setSurfaceModeLight(FlexSurfaceMode? value,
[bool notify = true]) async {
if (value == null) return;
if (value == _surfaceModeLight) return;
_surfaceModeLight = value;
if (notify) notifyListeners();
await _themeService.save(Store.keySurfaceModeLight, value);
}
late FlexSurfaceMode _surfaceModeDark;
FlexSurfaceMode get surfaceModeDark => _surfaceModeDark;
Future<void> setSurfaceModeDark(FlexSurfaceMode? value,
[bool notify = true]) async {
if (value == null) return;
if (value == _surfaceModeDark) return;
_surfaceModeDark = value;
if (notify) notifyListeners();
await _themeService.save(Store.keySurfaceModeDark, value);
}
late int _blendLevel;
int get blendLevel => _blendLevel;
Future<void> setBlendLevel(int? value, [bool notify = true]) async {
if (value == null) return;
if (value == _blendLevel) return;
_blendLevel = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyBlendLevel, value);
}
late int _blendLevelDark;
int get blendLevelDark => _blendLevelDark;
Future<void> setBlendLevelDark(int? value, [bool notify = true]) async {
if (value == null) return;
if (value == _blendLevelDark) return;
_blendLevelDark = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyBlendLevelDark, value);
}
late int _blendOnLevel;
int get blendOnLevel => _blendOnLevel;
Future<void> setBlendOnLevel(int? value, [bool notify = true]) async {
if (value == null) return;
if (value == _blendOnLevel) return;
_blendOnLevel = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyOnBlendLevel, value);
}
late int _blendOnLevelDark;
int get blendOnLevelDark => _blendOnLevelDark;
Future<void> setBlendOnLevelDark(int? value, [bool notify = true]) async {
if (value == null) return;
if (value == _blendOnLevelDark) return;
_blendOnLevelDark = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyBlendOnLevelDark, value);
}
late int _usedColors;
int get usedColors => _usedColors;
Future<void> setUsedColors(int? value, [bool notify = true]) async {
if (value == null) return;
if (value == _usedColors) return;
_usedColors = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyUsedColors, value);
}
late bool _swapLightColors;
bool get swapLightColors => _swapLightColors;
Future<void> setSwapLightColors(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _swapLightColors) return;
_swapLightColors = value;
if (notify) notifyListeners();
await _themeService.save(Store.keySwapLightColors, value);
}
late bool _swapDarkColors;
bool get swapDarkColors => _swapDarkColors;
Future<void> setSwapDarkColors(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _swapDarkColors) return;
_swapDarkColors = value;
if (notify) notifyListeners();
await _themeService.save(Store.keySwapDarkColors, value);
}
late bool _lightIsWhite;
bool get lightIsWhite => _lightIsWhite;
Future<void> setLightIsWhite(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _lightIsWhite) return;
_lightIsWhite = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyLightIsWhite, value);
}
late bool _darkIsTrueBlack;
bool get darkIsTrueBlack => _darkIsTrueBlack;
Future<void> setDarkIsTrueBlack(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _darkIsTrueBlack) return;
_darkIsTrueBlack = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyDarkIsTrueBlack, value);
}
late bool _useDarkColorsForSeed;
bool get useDarkColorsForSeed => _useDarkColorsForSeed;
Future<void> setUseDarkColorsForSeed(bool? value,
[bool notify = true]) async {
if (value == null) return;
if (value == _useDarkColorsForSeed) return;
_useDarkColorsForSeed = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyUseDarkColorsForSeed, value);
}
late bool _useToDarkMethod;
bool get useToDarkMethod => _useToDarkMethod;
Future<void> setUseToDarkMethod(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _useToDarkMethod) return;
_useToDarkMethod = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyUseToDarkMethod, value);
}
late bool _toDarkSwapPrimaryAndContainer;
bool get toDarkSwapPrimaryAndContainer => _toDarkSwapPrimaryAndContainer;
Future<void> setToDarkSwapPrimaryAndContainer(bool? value,
[bool notify = true]) async {
if (value == null) return;
if (value == _toDarkSwapPrimaryAndContainer) return;
_toDarkSwapPrimaryAndContainer = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyToDarkSwapPrimaryAndContainer, value);
}
late int _darkMethodLevel;
int get darkMethodLevel => _darkMethodLevel;
Future<void> setDarkMethodLevel(int? value, [bool notify = true]) async {
if (value == null) return;
if (value == _darkMethodLevel) return;
_darkMethodLevel = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyDarkMethodLevel, value);
}
// On color blending ON/OFF
late bool _blendLightOnColors;
bool get blendLightOnColors => _blendLightOnColors;
Future<void> setBlendLightOnColors(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _blendLightOnColors) return;
_blendLightOnColors = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyBlendLightOnColors, value);
}
late bool _blendDarkOnColors;
bool get blendDarkOnColors => _blendDarkOnColors;
Future<void> setBlendDarkOnColors(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _blendDarkOnColors) return;
_blendDarkOnColors = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyBlendDarkOnColors, value);
}
// TextThem blending ON/OFF
late bool _blendLightTextTheme;
bool get blendLightTextTheme => _blendLightTextTheme;
Future<void> setBlendLightTextTheme(bool? value, [bool notify = true]) async {
if (value == null) return;
if (value == _blendLightTextTheme) return;
_blendLightTextTheme = value;
if (notify) notifyListeners();
await _themeService.save(Store.keyBlendLightTextTheme, value);
}