/
generate_theme_dart_code.dart
902 lines (899 loc) · 39 KB
/
generate_theme_dart_code.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
// ignore_for_file: lines_longer_than_80_chars
import 'package:flex_color_scheme/flex_color_scheme.dart';
import 'package:flutter/material.dart';
import '../../shared/const/app_color.dart';
import '../../shared/controllers/theme_controller.dart';
/// A function that returns the FlexColorScheme Dart and Flutter setup
/// code for the theme held by ThemeController.
///
/// The properties are in the order they are in the classes.
String generateThemeDartCode(ThemeController controller) {
// If FlexColorsScheme is not in use, return a default M2 ColorScheme based
// theme as a starting point suggestion.
if (!controller.useFlexColorScheme) {
return '''
// FlexColorScheme is not in use!
// Here is a default Material 2 starting point theme setup for you.
//
theme: ThemeData.from(colorScheme: const ColorScheme.light()).copyWith(
typography: Typography.material2018(platform: defaultTargetPlatform),
),
darkTheme: ThemeData.from(colorScheme: const ColorScheme.dark()).copyWith(
typography: Typography.material2018(platform: defaultTargetPlatform),
),
themeMode: ThemeMode.system,''';
}
// Code for main theme setup, the effective colors setup.
final FlexSchemeData scheme = AppColor.scheme(controller);
// Get the enum index of scheme
final int flexScheme = controller.schemeIndex - 3;
// Using a built-in scheme or one of the custom colors in the demo?
final bool useBuiltIn = controller.schemeIndex > 2 &&
controller.schemeIndex < AppColor.schemes.length - 1;
final String lightScheme = useBuiltIn
? ' scheme: ${FlexScheme.values[flexScheme]},\n'
: ' colors: const FlexSchemeColor(\n'
' primary: ${scheme.light.primary},\n'
' primaryContainer: ${scheme.light.primaryContainer},\n'
' secondary: ${scheme.light.secondary},\n'
' secondaryContainer: ${scheme.light.secondaryContainer},\n'
' tertiary: ${scheme.light.tertiary},\n'
' tertiaryContainer: ${scheme.light.tertiaryContainer},\n'
' appBarColor: ${scheme.light.appBarColor},\n'
' error: ${scheme.light.error},\n'
' ),\n';
String darkScheme = useBuiltIn
? ' scheme: ${FlexScheme.values[flexScheme]},\n'
: ' colors: const FlexSchemeColor(\n'
' primary: ${scheme.dark.primary},\n'
' primaryContainer: ${scheme.dark.primaryContainer},\n'
' secondary: ${scheme.dark.secondary},\n'
' secondaryContainer: ${scheme.dark.secondaryContainer},\n'
' tertiary: ${scheme.dark.tertiary},\n'
' tertiaryContainer: ${scheme.dark.tertiaryContainer},\n'
' appBarColor: ${scheme.dark.appBarColor},\n'
' error: ${scheme.dark.error},\n'
' ),\n';
if (controller.useToDarkMethod && !useBuiltIn && !controller.useKeyColors) {
darkScheme = ' colors: const FlexSchemeColor(\n'
' primary: ${scheme.light.primary},\n'
' primaryContainer: ${scheme.light.primaryContainer},\n'
' secondary: ${scheme.light.secondary},\n'
' secondaryContainer: ${scheme.light.secondaryContainer},\n'
' tertiary: ${scheme.light.tertiary},\n'
' tertiaryContainer: ${scheme.light.tertiaryContainer},\n'
' appBarColor: ${scheme.light.appBarColor},\n'
' error: ${scheme.light.error},\n'
' ).defaultError.toDark(${controller.darkMethodLevel}, ${controller.toDarkSwapPrimaryAndContainer}),\n';
}
if (controller.useToDarkMethod && useBuiltIn && !controller.useKeyColors) {
darkScheme =
' colors: FlexColor.schemes[${FlexScheme.values[flexScheme]}]!\n'
' .light.defaultError.toDark(${controller.darkMethodLevel}, ${controller.toDarkSwapPrimaryAndContainer}),\n';
}
//
// Code for main theme setup, the other properties 'FlexColorScheme.light' and
// 'FlexColorScheme.dark' factories direct parameters.
// We avoid adding any code when API default values are being used.
//
final String surfaceModeLight = controller.blendLevel > 0 &&
controller.surfaceModeLight != FlexSurfaceMode.highScaffoldLowSurfaces
? ' surfaceMode: ${controller.surfaceModeLight},\n'
: '';
final String surfaceModeDark = controller.blendLevelDark > 0 &&
controller.surfaceModeDark != FlexSurfaceMode.highScaffoldLowSurfaces
? ' surfaceMode: ${controller.surfaceModeDark},\n'
: '';
final String blendLevel = controller.blendLevel > 0
? ' blendLevel: ${controller.blendLevel},\n'
: '';
final String usedColors = controller.usedColors != 6
? ' usedColors: ${controller.usedColors},\n'
: '';
final String blendLevelDark = controller.blendLevelDark > 0
? ' blendLevel: ${controller.blendLevelDark},\n'
: '';
final String appBarStyleLight =
controller.appBarStyleLight != FlexAppBarStyle.primary
? ' appBarStyle: ${controller.appBarStyleLight},\n'
: '';
final String appBarStyleDark =
controller.appBarStyleDark != FlexAppBarStyle.material
? ' appBarStyle: ${controller.appBarStyleDark},\n'
: '';
final String appBarOpacityLight = controller.appBarOpacityLight != 1
? ' appBarOpacity: ${controller.appBarOpacityLight.toStringAsFixed(2)},\n'
: '';
final String appBarOpacityDark = controller.appBarOpacityDark != 1
? ' appBarOpacity: ${controller.appBarOpacityDark.toStringAsFixed(2)},\n'
: '';
final String transparentStatusBar = controller.transparentStatusBar
? ''
: ' transparentStatusBar: ${controller.transparentStatusBar},\n';
final String appBarElevationLight = controller.appBarElevationLight != 0
? ' appBarElevation: ${controller.appBarElevationLight.toStringAsFixed(1)},\n'
: '';
final String appBarElevationDark = controller.appBarElevationDark != 0
? ' appBarElevation: ${controller.appBarElevationDark.toStringAsFixed(1)},\n'
: '';
final String tabBarStyle = controller.tabBarStyle != FlexTabBarStyle.forAppBar
? ' tabBarStyle: ${controller.tabBarStyle},\n'
: '';
final String lightIsWhite = controller.lightIsWhite
? ' lightIsWhite: ${controller.lightIsWhite},\n'
: '';
final String darkIsTrueBlack = controller.darkIsTrueBlack
? ' darkIsTrueBlack: ${controller.darkIsTrueBlack},\n'
: '';
final String swapLightColors = controller.swapLightColors
? ' swapColors: ${controller.swapLightColors},\n'
: '';
final String swapDarkColors = controller.swapDarkColors
? ' swapColors: ${controller.swapDarkColors},\n'
: '';
final String tooltipsMatchBackground = controller.tooltipsMatchBackground
? ' tooltipsMatchBackground: ${controller.tooltipsMatchBackground},\n'
: '';
final String useM3ErrorColors =
controller.useM3ErrorColors && !controller.useKeyColors
? ' useMaterial3ErrorColors: ${controller.useM3ErrorColors},\n'
: '';
final String useMaterial3 = controller.useMaterial3
? ' useMaterial3: ${controller.useMaterial3},\n'
: '';
final String tintLightColor = controller.surfaceTintLight != null
? ' surfaceTint: ${controller.surfaceTintLight},\n'
: '';
final String tintDarkColor = controller.surfaceTintDark != null
? ' surfaceTint: ${controller.surfaceTintDark},\n'
: '';
//
// Code for FlexSubThemesData setup.
//
final String interactionEffects = controller.interactionEffects
? ''
: ' interactionEffects: ${controller.interactionEffects},\n';
final String blendOnLevelLight = controller.blendOnLevel > 0
? ' blendOnLevel: ${controller.blendOnLevel},\n'
: '';
final String blendOnLevelDark = controller.blendOnLevelDark > 0
? ' blendOnLevel: ${controller.blendOnLevelDark},\n'
: '';
final String blendLightOnColors = controller.blendLightOnColors
? ''
: ' blendOnColors: ${controller.blendLightOnColors},\n';
final String blendDarkOnColors = controller.blendDarkOnColors
? ''
: ' blendOnColors: ${controller.blendDarkOnColors},\n';
final String blendLightTextTheme = controller.blendLightTextTheme
? ''
: ' blendTextTheme: ${controller.blendLightTextTheme},\n';
final String blendDarkTextTheme = controller.blendDarkTextTheme
? ''
: ' blendTextTheme: ${controller.blendDarkTextTheme},\n';
final String useTextTheme = controller.useTextTheme
? ''
: ' useTextTheme: ${controller.useTextTheme},\n';
final String useFlutterDefaults = controller.useFlutterDefaults
? ' useFlutterDefaults: ${controller.useFlutterDefaults},\n'
: '';
final String defRadius = controller.defaultRadius != null
? ' defaultRadius: ${controller.defaultRadius!.toStringAsFixed(1)},\n'
: '';
//
// Material bottom sheet.
final String bottomSheetRadius = controller.bottomSheetBorderRadius != null
? ' bottomSheetRadius: ${controller.bottomSheetBorderRadius!.toStringAsFixed(1)},\n'
: '';
//
// Material button sub themes border radius setup CODE.
//
final String textButtonBorderRadius = controller.textButtonBorderRadius !=
null
? ' textButtonRadius: ${controller.textButtonBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String elevatedButtonBorderRadius = controller
.elevatedButtonBorderRadius !=
null
? ' elevatedButtonRadius: ${controller.elevatedButtonBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String outlinedButtonBorderRadius = controller
.outlinedButtonBorderRadius !=
null
? ' outlinedButtonRadius: ${controller.outlinedButtonBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String toggleButtonsBorderRadius = controller
.toggleButtonsBorderRadius !=
null
? ' toggleButtonsRadius: ${controller.toggleButtonsBorderRadius!.toStringAsFixed(1)},\n'
: '';
//
// Material button sub themes scheme colors setup CODE.
//
final String textButtonSchemeColor =
controller.textButtonSchemeColor == SchemeColor.primary ||
controller.textButtonSchemeColor == null
? ''
: ' textButtonSchemeColor: ${controller.textButtonSchemeColor},\n';
final String elevatedButtonSchemeColor = controller
.elevatedButtonSchemeColor ==
SchemeColor.primary ||
controller.elevatedButtonSchemeColor == null
? ''
: ' elevatedButtonSchemeColor: ${controller.elevatedButtonSchemeColor},\n';
final String outlinedButtonSchemeColor = controller
.outlinedButtonSchemeColor ==
SchemeColor.primary ||
controller.outlinedButtonSchemeColor == null
? ''
: ' outlinedButtonSchemeColor: ${controller.outlinedButtonSchemeColor},\n';
final String toggleButtonsSchemeColor = controller.toggleButtonsSchemeColor ==
SchemeColor.primary ||
controller.toggleButtonsSchemeColor == null
? ''
: ' toggleButtonsSchemeColor: ${controller.toggleButtonsSchemeColor},\n';
//
// Toggleable sub themes setup CODE.
//
final String switchSchemeColor =
controller.switchSchemeColor == SchemeColor.secondary ||
controller.switchSchemeColor == null
? ''
: ' switchSchemeColor: ${controller.switchSchemeColor},\n';
final String checkboxSchemeColor =
controller.checkboxSchemeColor == SchemeColor.secondary ||
controller.checkboxSchemeColor == null
? ''
: ' checkboxSchemeColor: ${controller.checkboxSchemeColor},\n';
final String radioSchemeColor =
controller.radioSchemeColor == SchemeColor.secondary ||
controller.radioSchemeColor == null
? ''
: ' radioSchemeColor: ${controller.radioSchemeColor},\n';
final String unselectedIsColored = controller.unselectedToggleIsColored
? ' unselectedToggleIsColored: ${controller.unselectedToggleIsColored},\n'
: '';
//
// Input decorator setup CODE.
//
final String inputDecoratorSchemeColorLight = controller
.inputDecoratorSchemeColorLight ==
SchemeColor.primary ||
controller.inputDecoratorSchemeColorLight == null
? ''
: ' inputDecoratorSchemeColor: ${controller.inputDecoratorSchemeColorLight},\n';
final String inputDecoratorSchemeColorDark = controller
.inputDecoratorSchemeColorDark ==
SchemeColor.primary ||
controller.inputDecoratorSchemeColorDark == null
? ''
: ' inputDecoratorSchemeColor: ${controller.inputDecoratorSchemeColorDark},\n';
final String inputDecoratorIsFilled = controller.inputDecoratorIsFilled
? ''
: ' inputDecoratorIsFilled: ${controller.inputDecoratorIsFilled},\n';
final String inputDecoratorBorderType = controller.inputDecoratorBorderType ==
FlexInputBorderType.outline
? ''
: ' inputDecoratorBorderType: ${controller.inputDecoratorBorderType},\n';
final String inputDecoratorBorderRadius = controller
.inputDecoratorBorderRadius !=
null
? ' inputDecoratorRadius: ${controller.inputDecoratorBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String inputDecoratorUnfocusedHasBorder = controller
.inputDecoratorUnfocusedHasBorder
? ''
: ' inputDecoratorUnfocusedHasBorder: ${controller.inputDecoratorUnfocusedHasBorder},\n';
final String inputDecoratorUnfocusedBorderIsColored = controller
.inputDecoratorUnfocusedBorderIsColored ||
!controller.inputDecoratorUnfocusedHasBorder
? ''
: ' inputDecoratorUnfocusedBorderIsColored: ${controller.inputDecoratorUnfocusedBorderIsColored},\n';
//
// Fab and chip, snack, card, dialog, popup setup CODE
//
final String fabUseShape = controller.fabUseShape
? ''
: ' fabUseShape: ${controller.fabUseShape},\n';
final String fabBorderRadius = controller.fabBorderRadius != null &&
controller.fabUseShape
? ' fabRadius: ${controller.fabBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String fabSchemeColor =
controller.fabSchemeColor == SchemeColor.secondary ||
controller.fabSchemeColor == null
? ''
: ' fabSchemeColor: ${controller.fabSchemeColor},\n';
final String snackSchemeColor = controller.snackBarSchemeColor != null
? ' snackBarBackgroundSchemeColor: ${controller.snackBarSchemeColor},\n'
: '';
final String chipSchemeColor = controller.chipSchemeColor != null
? ' chipSchemeColor: ${controller.chipSchemeColor},\n'
: '';
final String chipBorderRadius = controller.chipBorderRadius != null
? ' chipRadius: ${controller.chipBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String cardBorderRadius = controller.cardBorderRadius != null
? ' cardRadius: ${controller.cardBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String popupMenuOpacity = controller.popupMenuOpacity != 1
? ' popupMenuOpacity: ${controller.popupMenuOpacity.toStringAsFixed(2)},\n'
: '';
final String popupMenuBorderRadius = controller.popupMenuBorderRadius != null
? ' popupMenuRadius: ${controller.popupMenuBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String dialogBackgroundSchemeColor = controller
.dialogBackgroundSchemeColor !=
null
? ' dialogBackgroundSchemeColor: ${controller.dialogBackgroundSchemeColor},\n'
: '';
final String dialogBorderRadius = controller.dialogBorderRadius != null
? ' dialogRadius: ${controller.dialogBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String timePickerDialogRadius = controller.dialogBorderRadius != null
? ' timePickerDialogRadius: ${controller.dialogBorderRadius!.toStringAsFixed(1)},\n'
: '';
final String appBarBackgroundSchemeColorLight = controller
.appBarBackgroundSchemeColorLight !=
null
? ' appBarBackgroundSchemeColor: ${controller.appBarBackgroundSchemeColorLight},\n'
: '';
final String appBarBackgroundSchemeColorDark = controller
.appBarBackgroundSchemeColorDark !=
null
? ' appBarBackgroundSchemeColor: ${controller.appBarBackgroundSchemeColorDark},\n'
: '';
final String tabBarItemSchemeColorLight = controller
.tabBarItemSchemeColorLight !=
null
? ' tabBarItemSchemeColor: ${controller.tabBarItemSchemeColorLight},\n'
: '';
final String tabBarIndicatorSchemeColorLight = controller
.tabBarIndicatorLight !=
null
? ' tabBarIndicatorSchemeColor: ${controller.tabBarIndicatorLight},\n'
: '';
final String tabBarItemSchemeColorDark = controller
.tabBarItemSchemeColorDark !=
null
? ' tabBarItemSchemeColor: ${controller.tabBarItemSchemeColorDark},\n'
: '';
final String tabBarIndicatorSchemeColorDark = controller
.tabBarIndicatorDark !=
null
? ' tabBarIndicatorSchemeColor: ${controller.tabBarIndicatorDark},\n'
: '';
//
// BottomNavigationBar setup CODE
//
final String bottomNavigationBarSelectedLabelSchemeColor = controller
.bottomNavBarSelectedSchemeColor !=
null
? ' bottomNavigationBarSelectedLabelSchemeColor: ${controller.bottomNavBarSelectedSchemeColor},\n'
: '';
final String bottomNavigationBarUnselectedLabelSchemeColor = controller
.bottomNavBarUnselectedSchemeColor !=
null
? ' bottomNavigationBarUnselectedLabelSchemeColor: ${controller.bottomNavBarUnselectedSchemeColor},\n'
: '';
final String bottomNavigationBarMutedUnselectedLabel = controller
.bottomNavBarMuteUnselected ||
(controller.useFlutterDefaults &&
controller.bottomNavBarSelectedSchemeColor == null &&
controller.bottomNavBarUnselectedSchemeColor == null)
? ''
: ' bottomNavigationBarMutedUnselectedLabel: ${controller.bottomNavBarMuteUnselected},\n';
final String bottomNavigationBarSelectedIconSchemeColor = controller
.bottomNavBarSelectedSchemeColor !=
null
? ' bottomNavigationBarSelectedIconSchemeColor: ${controller.bottomNavBarSelectedSchemeColor},\n'
: '';
final String bottomNavigationBarUnselectedIconSchemeColor = controller
.bottomNavBarUnselectedSchemeColor !=
null
? ' bottomNavigationBarUnselectedIconSchemeColor: ${controller.bottomNavBarUnselectedSchemeColor},\n'
: '';
final String bottomNavigationBarMutedUnselectedIcon = controller
.bottomNavBarMuteUnselected ||
(controller.useFlutterDefaults &&
controller.bottomNavBarSelectedSchemeColor == null &&
controller.bottomNavBarUnselectedSchemeColor == null)
? ''
: ' bottomNavigationBarMutedUnselectedIcon: ${controller.bottomNavBarMuteUnselected},\n';
final String bottomNavigationBarBackgroundSchemeColor = controller
.bottomNavBarBackgroundSchemeColor !=
null
? ' bottomNavigationBarBackgroundSchemeColor: ${controller.bottomNavBarBackgroundSchemeColor},\n'
: '';
final String bottomNavigationBarOpacity = controller
.bottomNavigationBarOpacity !=
1 &&
!(controller.bottomNavBarBackgroundSchemeColor == null &&
controller.useFlutterDefaults)
? ' bottomNavigationBarOpacity: ${controller.bottomNavigationBarOpacity.toStringAsFixed(2)},\n'
: '';
final String bottomNavigationBarElevation = controller
.bottomNavigationBarElevation !=
0
? ' bottomNavigationBarElevation: ${controller.bottomNavigationBarElevation.toStringAsFixed(1)},\n'
: '';
final String bottomNavigationBarShowSelectedLabels = controller
.bottomNavShowSelectedLabels
? ''
: ' bottomNavigationBarShowSelectedLabels: ${controller.bottomNavShowSelectedLabels},\n';
final String bottomNavigationBarShowUnselectedLabels = controller
.bottomNavShowUnselectedLabels
? ''
: ' bottomNavigationBarShowUnselectedLabels: ${controller.bottomNavShowUnselectedLabels},\n';
//
// NavigationBar setup CODE
//
final String navigationBarSelectedLabelSchemeColor = controller
.navBarSelectedSchemeColor !=
null
? ' navigationBarSelectedLabelSchemeColor: ${controller.navBarSelectedSchemeColor},\n'
: '';
final String navigationBarUnselectedLabelSchemeColor = controller
.navBarUnselectedSchemeColor !=
null
? ' navigationBarUnselectedLabelSchemeColor: ${controller.navBarUnselectedSchemeColor},\n'
: '';
final String navigationBarMutedUnselectedLabel = controller
.navBarMuteUnselected
? ''
: ' navigationBarMutedUnselectedLabel: ${controller.navBarMuteUnselected},\n';
final String navigationBarSelectedIconSchemeColor = controller
.navBarSelectedSchemeColor !=
null
? ' navigationBarSelectedIconSchemeColor: ${controller.navBarSelectedSchemeColor},\n'
: '';
final String navigationBarUnselectedIconSchemeColor = controller
.navBarUnselectedSchemeColor !=
null
? ' navigationBarUnselectedIconSchemeColor: ${controller.navBarUnselectedSchemeColor},\n'
: '';
final String navigationBarMutedUnselectedIcon = controller
.navBarMuteUnselected
? ''
: ' navigationBarMutedUnselectedIcon: ${controller.navBarMuteUnselected},\n';
final String navigationBarIndicatorSchemeColor = controller
.navBarIndicatorSchemeColor !=
null
? ' navigationBarIndicatorSchemeColor: ${controller.navBarIndicatorSchemeColor},\n'
: '';
final String navigationBarIndicatorOpacity = controller
.navBarIndicatorOpacity !=
null &&
!(controller.navBarIndicatorSchemeColor == null &&
controller.useFlutterDefaults)
? ' navigationBarIndicatorOpacity: ${controller.navBarIndicatorOpacity!.toStringAsFixed(2)},\n'
: '';
final String navigationBarBackgroundSchemeColor = controller
.navBarBackgroundSchemeColor !=
null
? ' navigationBarBackgroundSchemeColor: ${controller.navBarBackgroundSchemeColor},\n'
: '';
final String navigationBarOpacity = controller.navBarOpacity != 1 &&
!(controller.navBarBackgroundSchemeColor == null &&
controller.useFlutterDefaults)
? ' navigationBarOpacity: ${controller.navBarOpacity.toStringAsFixed(2)},\n'
: '';
final String navigationBarHeight = controller.navBarHeight != null
? ' navigationBarHeight: ${controller.navBarHeight!.toStringAsFixed(1)},\n'
: '';
final String navigationBarLabelBehavior = controller.navBarLabelBehavior !=
NavigationDestinationLabelBehavior.alwaysShow
? ' navigationBarLabelBehavior: ${controller.navBarLabelBehavior},\n'
: '';
//
// NavigationRail setup CODE
//
final String navigationRailSelectedLabelSchemeColor = controller
.navRailSelectedSchemeColor !=
null
? ' navigationRailSelectedLabelSchemeColor: ${controller.navRailSelectedSchemeColor},\n'
: '';
final String navigationRailUnselectedLabelSchemeColor = controller
.navRailUnselectedSchemeColor !=
null
? ' navigationRailUnselectedLabelSchemeColor: ${controller.navRailUnselectedSchemeColor},\n'
: '';
final String navigationRailMutedUnselectedLabel = controller
.navRailMuteUnselected ||
(controller.useFlutterDefaults &&
controller.navRailSelectedSchemeColor == null &&
controller.navRailUnselectedSchemeColor == null)
? ''
: ' navigationRailMutedUnselectedLabel: ${controller.navRailMuteUnselected},\n';
final String navigationRailSelectedIconSchemeColor = controller
.navRailSelectedSchemeColor !=
null
? ' navigationRailSelectedIconSchemeColor: ${controller.navRailSelectedSchemeColor},\n'
: '';
final String navigationRailUnselectedIconSchemeColor = controller
.navRailUnselectedSchemeColor !=
null
? ' navigationRailUnselectedIconSchemeColor: ${controller.navRailUnselectedSchemeColor},\n'
: '';
final String navigationRailMutedUnselectedIcon = controller
.navRailMuteUnselected ||
(controller.useFlutterDefaults &&
controller.navRailSelectedSchemeColor == null &&
controller.navRailUnselectedSchemeColor == null)
? ''
: ' navigationRailMutedUnselectedIcon: ${controller.navRailMuteUnselected},\n';
final String navigationRailUseIndicator = controller.navRailUseIndicator
? ''
: ' navigationRailUseIndicator: ${controller.navRailUseIndicator},\n';
final String navigationRailIndicatorSchemeColor = controller
.navRailIndicatorSchemeColor !=
null &&
controller.navRailUseIndicator
? ' navigationRailIndicatorSchemeColor: ${controller.navRailIndicatorSchemeColor},\n'
: '';
final String navigationRailIndicatorOpacity = controller
.navRailIndicatorOpacity !=
null &&
!(controller.navRailIndicatorSchemeColor == null &&
controller.navRailUseIndicator &&
controller.useFlutterDefaults)
? ' navigationRailIndicatorOpacity: ${controller.navRailIndicatorOpacity!.toStringAsFixed(2)},\n'
: '';
final String navigationRailBackgroundSchemeColor = controller
.navRailBackgroundSchemeColor !=
null
? ' navigationRailBackgroundSchemeColor: ${controller.navRailBackgroundSchemeColor},\n'
: '';
final String navigationRailOpacity = controller.navRailOpacity != 1 &&
!(controller.navRailBackgroundSchemeColor == null &&
controller.useFlutterDefaults)
? ' navigationRailOpacity: ${controller.navRailOpacity.toStringAsFixed(2)},\n'
: '';
final String navigationRailElevation = controller.navigationRailElevation != 0
? ' navigationRailElevation: ${controller.navigationRailElevation.toStringAsFixed(1)},\n'
: '';
final String navigationRailLabelType =
controller.navRailLabelType != NavigationRailLabelType.all
? ' navigationRailLabelType: ${controller.navRailLabelType},\n'
: '';
//
// Compose the sub themes from above fragments.
//
String lightSubTheme = controller.useSubThemes
? ' subThemesData: const FlexSubThemesData(\n'
'$useFlutterDefaults'
'$interactionEffects'
'$blendOnLevelLight'
'$blendLightOnColors'
'$blendLightTextTheme'
'$useTextTheme'
'$defRadius'
//
'$bottomSheetRadius'
'$textButtonBorderRadius'
'$elevatedButtonBorderRadius'
'$outlinedButtonBorderRadius'
'$toggleButtonsBorderRadius'
//
'$textButtonSchemeColor'
'$elevatedButtonSchemeColor'
'$outlinedButtonSchemeColor'
'$toggleButtonsSchemeColor'
//
'$switchSchemeColor'
'$checkboxSchemeColor'
'$radioSchemeColor'
'$unselectedIsColored'
//
'$inputDecoratorSchemeColorLight'
'$inputDecoratorIsFilled'
'$inputDecoratorBorderType'
'$inputDecoratorBorderRadius'
'$inputDecoratorUnfocusedHasBorder'
'$inputDecoratorUnfocusedBorderIsColored'
//
'$fabUseShape'
'$fabBorderRadius'
'$fabSchemeColor'
'$snackSchemeColor'
'$chipSchemeColor'
'$chipBorderRadius'
'$cardBorderRadius'
//
'$popupMenuOpacity'
'$popupMenuBorderRadius'
'$dialogBackgroundSchemeColor'
'$dialogBorderRadius'
'$timePickerDialogRadius'
'$appBarBackgroundSchemeColorLight'
'$tabBarItemSchemeColorLight'
'$tabBarIndicatorSchemeColorLight'
//
'$bottomNavigationBarSelectedLabelSchemeColor'
'$bottomNavigationBarUnselectedLabelSchemeColor'
'$bottomNavigationBarMutedUnselectedLabel'
'$bottomNavigationBarSelectedIconSchemeColor'
'$bottomNavigationBarUnselectedIconSchemeColor'
'$bottomNavigationBarMutedUnselectedIcon'
'$bottomNavigationBarBackgroundSchemeColor'
'$bottomNavigationBarOpacity'
'$bottomNavigationBarElevation'
'$bottomNavigationBarShowSelectedLabels'
'$bottomNavigationBarShowUnselectedLabels'
//
'$navigationBarSelectedLabelSchemeColor'
'$navigationBarUnselectedLabelSchemeColor'
'$navigationBarMutedUnselectedLabel'
'$navigationBarSelectedIconSchemeColor'
'$navigationBarUnselectedIconSchemeColor'
'$navigationBarMutedUnselectedIcon'
'$navigationBarIndicatorSchemeColor'
'$navigationBarIndicatorOpacity'
'$navigationBarBackgroundSchemeColor'
'$navigationBarOpacity'
'$navigationBarHeight'
'$navigationBarLabelBehavior'
//
'$navigationRailSelectedLabelSchemeColor'
'$navigationRailUnselectedLabelSchemeColor'
'$navigationRailMutedUnselectedLabel'
'$navigationRailSelectedIconSchemeColor'
'$navigationRailUnselectedIconSchemeColor'
'$navigationRailMutedUnselectedIcon'
'$navigationRailUseIndicator'
'$navigationRailIndicatorSchemeColor'
'$navigationRailIndicatorOpacity'
'$navigationRailBackgroundSchemeColor'
'$navigationRailOpacity'
'$navigationRailElevation'
'$navigationRailLabelType'
//
' ),\n'
: '';
String darkSubTheme = controller.useSubThemes
? ' subThemesData: const FlexSubThemesData(\n'
'$useFlutterDefaults'
'$interactionEffects'
'$blendOnLevelDark'
'$blendDarkOnColors'
'$blendDarkTextTheme'
'$useTextTheme'
'$defRadius'
//
'$bottomSheetRadius'
'$textButtonBorderRadius'
'$elevatedButtonBorderRadius'
'$outlinedButtonBorderRadius'
'$toggleButtonsBorderRadius'
//
'$textButtonSchemeColor'
'$elevatedButtonSchemeColor'
'$outlinedButtonSchemeColor'
'$toggleButtonsSchemeColor'
//
'$switchSchemeColor'
'$checkboxSchemeColor'
'$radioSchemeColor'
'$unselectedIsColored'
//
'$inputDecoratorSchemeColorDark'
'$inputDecoratorIsFilled'
'$inputDecoratorBorderType'
'$inputDecoratorBorderRadius'
'$inputDecoratorUnfocusedHasBorder'
'$inputDecoratorUnfocusedBorderIsColored'
//
'$fabUseShape'
'$fabBorderRadius'
'$fabSchemeColor'
'$snackSchemeColor'
'$chipSchemeColor'
'$chipBorderRadius'
'$cardBorderRadius'
//
'$popupMenuOpacity'
'$popupMenuBorderRadius'
'$dialogBackgroundSchemeColor'
'$dialogBorderRadius'
'$timePickerDialogRadius'
'$appBarBackgroundSchemeColorDark'
'$tabBarItemSchemeColorDark'
'$tabBarIndicatorSchemeColorDark'
//
'$bottomNavigationBarSelectedLabelSchemeColor'
'$bottomNavigationBarUnselectedLabelSchemeColor'
'$bottomNavigationBarMutedUnselectedLabel'
'$bottomNavigationBarSelectedIconSchemeColor'
'$bottomNavigationBarUnselectedIconSchemeColor'
'$bottomNavigationBarMutedUnselectedIcon'
'$bottomNavigationBarBackgroundSchemeColor'
'$bottomNavigationBarOpacity'
'$bottomNavigationBarElevation'
'$bottomNavigationBarShowSelectedLabels'
'$bottomNavigationBarShowUnselectedLabels'
//
'$navigationBarSelectedLabelSchemeColor'
'$navigationBarUnselectedLabelSchemeColor'
'$navigationBarMutedUnselectedLabel'
'$navigationBarSelectedIconSchemeColor'
'$navigationBarUnselectedIconSchemeColor'
'$navigationBarMutedUnselectedIcon'
'$navigationBarIndicatorSchemeColor'
'$navigationBarIndicatorOpacity'
'$navigationBarBackgroundSchemeColor'
'$navigationBarOpacity'
'$navigationBarHeight'
'$navigationBarLabelBehavior'
//
'$navigationRailSelectedLabelSchemeColor'
'$navigationRailUnselectedLabelSchemeColor'
'$navigationRailMutedUnselectedLabel'
'$navigationRailSelectedIconSchemeColor'
'$navigationRailUnselectedIconSchemeColor'
'$navigationRailMutedUnselectedIcon'
'$navigationRailUseIndicator'
'$navigationRailIndicatorSchemeColor'
'$navigationRailIndicatorOpacity'
'$navigationRailBackgroundSchemeColor'
'$navigationRailOpacity'
'$navigationRailElevation'
'$navigationRailLabelType'
' ),\n'
: '';
// Make a prettier version of the constructor if we have default one.
if (lightSubTheme == ' subThemesData: const FlexSubThemesData(\n ),\n') {
lightSubTheme = ' subThemesData: const FlexSubThemesData(),\n';
}
if (darkSubTheme == ' subThemesData: const FlexSubThemesData(\n ),\n') {
darkSubTheme = ' subThemesData: const FlexSubThemesData(),\n';
}
//
// Define code for key color usage and tones.
final String useSecondary = controller.useSecondary
? ' useSecondary: ${controller.useSecondary},\n'
: '';
final String useTertiary = controller.useTertiary
? ' useTertiary: ${controller.useTertiary},\n'
: '';
final String keepPrimary = controller.keepPrimary
? ' keepPrimary: ${controller.keepPrimary},\n'
: '';
final String keepSecondary = controller.keepSecondary
? ' keepSecondary: ${controller.keepSecondary},\n'
: '';
final String keepTertiary = controller.keepTertiary
? ' keepTertiary: ${controller.keepTertiary},\n'
: '';
final String keepPrimaryContainer = controller.keepPrimaryContainer
? ' keepPrimaryContainer: ${controller.keepPrimaryContainer},\n'
: '';
final String keepSecondaryContainer = controller.keepSecondaryContainer
? ' keepSecondaryContainer: ${controller.keepSecondaryContainer},\n'
: '';
final String keepTertiaryContainer = controller.keepTertiaryContainer
? ' keepTertiaryContainer: ${controller.keepTertiaryContainer},\n'
: '';
final String keepDarkPrimary = controller.keepDarkPrimary
? ' keepPrimary: ${controller.keepDarkPrimary},\n'
: '';
final String keepDarkSecondary = controller.keepDarkSecondary
? ' keepSecondary: ${controller.keepDarkSecondary},\n'
: '';
final String keepDarkTertiary = controller.keepDarkTertiary
? ' keepTertiary: ${controller.keepDarkTertiary},\n'
: '';
final String keepDarkPrimaryContainer = controller.keepDarkPrimaryContainer
? ' keepPrimaryContainer: ${controller.keepDarkPrimaryContainer},\n'
: '';
final String keepDarkSecondaryContainer = controller
.keepDarkSecondaryContainer
? ' keepSecondaryContainer: ${controller.keepDarkSecondaryContainer},\n'
: '';
final String keepDarkTertiaryContainer = controller.keepDarkTertiaryContainer
? ' keepTertiaryContainer: ${controller.keepDarkTertiaryContainer},\n'
: '';
String useKeyColorsLight = controller.useKeyColors
? ' keyColors: const FlexKeyColors(\n'
'$useSecondary'
'$useTertiary'
'$keepPrimary'
'$keepSecondary'
'$keepTertiary'
'$keepPrimaryContainer'
'$keepSecondaryContainer'
'$keepTertiaryContainer'
' ),\n'
: '';
String useKeyColorsDark = controller.useKeyColors
? ' keyColors: const FlexKeyColors(\n'
'$useSecondary'
'$useTertiary'
'$keepDarkPrimary'
'$keepDarkSecondary'
'$keepDarkTertiary'
'$keepDarkPrimaryContainer'
'$keepDarkSecondaryContainer'
'$keepDarkTertiaryContainer'
' ),\n'
: '';
// Make a prettier version of the constructor if that is all we got.
if (useKeyColorsLight == ' keyColors: const FlexKeyColors(\n ),\n') {
useKeyColorsLight = ' keyColors: const FlexKeyColors(),\n';
}
if (useKeyColorsDark == ' keyColors: const FlexKeyColors(\n ),\n') {
useKeyColorsDark = ' keyColors: const FlexKeyColors(),\n';
}
String flexTonesLight = '';
String flexTonesDark = '';
if (controller.useKeyColors) {
if (controller.usedFlexToneSetup == 2) {
flexTonesLight = ' tones: FlexTones.soft(Brightness.light),\n';
flexTonesDark = ' tones: FlexTones.soft(Brightness.dark),\n';
}
if (controller.usedFlexToneSetup == 3) {
flexTonesLight = ' tones: FlexTones.vivid(Brightness.light),\n';
flexTonesDark = ' tones: FlexTones.vivid(Brightness.dark),\n';
}
if (controller.usedFlexToneSetup == 4) {
flexTonesLight = ' tones: FlexTones.vividSurfaces(Brightness.light),\n';
flexTonesDark = ' tones: FlexTones.vividSurfaces(Brightness.dark),\n';
}
if (controller.usedFlexToneSetup == 5) {
flexTonesLight = ' tones: FlexTones.highContrast(Brightness.light),\n';
flexTonesDark = ' tones: FlexTones.highContrast(Brightness.dark),\n';
}
}
//
// Compose the final FlexThemeData code string, from all above fragments.
//
final String code = 'theme: FlexThemeData.light(\n'
'$lightScheme'
'$usedColors'
'$surfaceModeLight'
'$blendLevel'
'$appBarStyleLight'
'$appBarOpacityLight'
'$transparentStatusBar'
'$appBarElevationLight'
'$tabBarStyle'
'$lightIsWhite'
'$swapLightColors'
'$tintLightColor'
'$tooltipsMatchBackground'
'$lightSubTheme'
'$useKeyColorsLight'
'$useM3ErrorColors'
'$flexTonesLight'
' visualDensity: FlexColorScheme.comfortablePlatformDensity,\n'
'$useMaterial3'
' // To use the playground font, add GoogleFonts package and uncomment\n'
' // fontFamily: GoogleFonts.notoSans().fontFamily,\n'
'),\n'
'darkTheme: FlexThemeData.dark(\n'
'$darkScheme'
'$usedColors'
'$surfaceModeDark'
'$blendLevelDark'
'$appBarStyleDark'
'$appBarOpacityDark'
'$transparentStatusBar'
'$appBarElevationDark'
'$tabBarStyle'
'$darkIsTrueBlack'
'$swapDarkColors'
'$tintDarkColor'
'$tooltipsMatchBackground'
'$darkSubTheme'
'$useKeyColorsDark'
'$useM3ErrorColors'
'$flexTonesDark'
' visualDensity: FlexColorScheme.comfortablePlatformDensity,\n'
'$useMaterial3'
' // To use the playground font, add GoogleFonts package and uncomment\n'
' // fontFamily: GoogleFonts.notoSans().fontFamily,\n'
'),\n'
'// If you do not have a themeMode switch, uncomment this line\n'
'// to let the device system mode control the theme mode:\n'
'// themeMode: ThemeMode.system,\n';
return code;
}