-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Expand file tree
/
Copy pathcolor_scheme.dart
More file actions
2239 lines (2104 loc) · 86.6 KB
/
Copy pathcolor_scheme.dart
File metadata and controls
2239 lines (2104 loc) · 86.6 KB
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
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// @docImport 'input_decorator.dart';
/// @docImport 'scaffold.dart';
library;
import 'dart:async';
import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:material_color_utilities/material_color_utilities.dart';
import 'colors.dart';
import 'theme.dart';
/// The algorithm used to construct a [ColorScheme] in [ColorScheme.fromSeed].
///
/// The `tonalSpot` variant builds default Material scheme colors. These colors are
/// mapped to light or dark tones to achieve visually accessible color
/// pairings with sufficient contrast between foreground and background elements.
///
/// In some cases, the tones can prevent colors from appearing as intended,
/// such as when a color is too light to offer enough contrast for accessibility.
/// Color fidelity (`DynamicSchemeVariant.fidelity`) is a feature that adjusts
/// tones in these cases to produce the intended visual results without harming
/// visual contrast.
enum DynamicSchemeVariant {
/// Default for Material theme colors. Builds pastel palettes with a low chroma.
tonalSpot,
/// The resulting color palettes match seed color, even if the seed color
/// is very bright (high chroma).
fidelity,
/// All colors are grayscale, no chroma.
monochrome,
/// Close to grayscale, a hint of chroma.
neutral,
/// Pastel colors, high chroma palettes. The primary palette's chroma is at
/// maximum. Use `fidelity` instead if tokens should alter their tone to match
/// the palette vibrancy.
vibrant,
/// Pastel colors, medium chroma palettes. The primary palette's hue is
/// different from the seed color, for variety.
expressive,
/// Almost identical to `fidelity`. Tokens and palettes match the seed color.
/// [ColorScheme.primaryContainer] is the seed color, adjusted to ensure
/// contrast with surfaces. The tertiary palette is analogue of the seed color.
content,
/// A playful theme - the seed color's hue does not appear in the theme.
rainbow,
/// A playful theme - the seed color's hue does not appear in the theme.
fruitSalad,
}
/// {@template flutter.material.color_scheme.ColorScheme}
/// A set of 45 colors based on the
/// [Material spec](https://m3.material.io/styles/color/the-color-system/color-roles)
/// that can be used to configure the color properties of most components.
/// {@endtemplate}
///
/// ### Colors in Material 3
///
/// {@macro flutter.material.colors.colorRoles}
///
/// The main accent color groups in the scheme are [primary], [secondary],
/// and [tertiary].
///
/// * Primary colors are used for key components across the UI, such as the FAB,
/// prominent buttons, and active states.
///
/// * Secondary colors are used for less prominent components in the UI, such as
/// filter chips, while expanding the opportunity for color expression.
///
/// * Tertiary colors are used for contrasting accents that can be used to
/// balance primary and secondary colors or bring heightened attention to
/// an element, such as an input field. The tertiary colors are left
/// for makers to use at their discretion and are intended to support
/// broader color expression in products.
///
/// Each accent color group (primary, secondary and tertiary) includes '-Fixed'
/// '-Dim' color roles, such as [primaryFixed] and [primaryFixedDim]. Fixed roles
/// are appropriate to use in places where Container roles are normally used,
/// but they stay the same color between light and dark themes. The '-Dim' roles
/// provide a stronger, more emphasized color with the same fixed behavior.
///
/// The remaining colors of the scheme are composed of neutral colors used for
/// backgrounds and surfaces, as well as specific colors for errors, dividers
/// and shadows. Surface colors are used for backgrounds and large, low-emphasis
/// areas of the screen.
///
/// Material 3 also introduces tone-based surfaces and surface containers.
/// They replace the old opacity-based model which applied a tinted overlay on
/// top of surfaces based on their elevation. These colors include: [surfaceBright],
/// [surfaceDim], [surfaceContainerLowest], [surfaceContainerLow], [surfaceContainer],
/// [surfaceContainerHigh], and [surfaceContainerHighest].
///
/// Many of the colors have matching 'on' colors, which are used for drawing
/// content on top of the matching color. For example, if something is using
/// [primary] for a background color, [onPrimary] would be used to paint text
/// and icons on top of it. For this reason, the 'on' colors should have a
/// contrast ratio with their matching colors of at least 4.5:1 in order to
/// be readable. On '-FixedVariant' roles, such as [onPrimaryFixedVariant],
/// also have the same color between light and dark themes, but compared
/// with on '-Fixed' roles, such as [onPrimaryFixed], they provide a
/// lower-emphasis option for text and icons.
///
/// {@tool dartpad}
/// This example shows all Material [ColorScheme] roles in light and dark
/// brightnesses.
///
/// ** See code in examples/api/lib/material/color_scheme/color_scheme.0.dart **
/// {@end-tool}
///
/// ### Setting Colors in Flutter
///
///{@macro flutter.material.colors.settingColors}
@immutable
class ColorScheme with Diagnosticable {
/// Create a ColorScheme instance from the given colors.
///
/// [ColorScheme.fromSeed] can be used as a simpler way to create a full
/// color scheme derived from a single seed color.
///
/// For the color parameters that are nullable, it is still recommended
/// that applications provide values for them. They are only nullable due
/// to backwards compatibility concerns.
///
/// If a color is not provided, the closest fallback color from the given
/// colors will be used for it (e.g. [primaryContainer] will default
/// to [primary]). Material Design 3 makes use of these colors for many
/// component defaults, so for the best results the application should
/// supply colors for all the parameters. An easy way to ensure this is to
/// use [ColorScheme.fromSeed] to generate a full set of colors.
///
/// During the migration to Material Design 3, if an app's
/// [ThemeData.useMaterial3] is false, then components will only
/// use the following colors for defaults:
///
/// * [primary]
/// * [onPrimary]
/// * [secondary]
/// * [onSecondary]
/// * [error]
/// * [onError]
/// * [surface]
/// * [onSurface]
/// DEPRECATED:
/// * [background]
/// * [onBackground]
const ColorScheme({
required this.brightness,
required this.primary,
required this.onPrimary,
Color? primaryContainer,
Color? onPrimaryContainer,
Color? primaryFixed,
Color? primaryFixedDim,
Color? onPrimaryFixed,
Color? onPrimaryFixedVariant,
required this.secondary,
required this.onSecondary,
Color? secondaryContainer,
Color? onSecondaryContainer,
Color? secondaryFixed,
Color? secondaryFixedDim,
Color? onSecondaryFixed,
Color? onSecondaryFixedVariant,
Color? tertiary,
Color? onTertiary,
Color? tertiaryContainer,
Color? onTertiaryContainer,
Color? tertiaryFixed,
Color? tertiaryFixedDim,
Color? onTertiaryFixed,
Color? onTertiaryFixedVariant,
required this.error,
required this.onError,
Color? errorContainer,
Color? onErrorContainer,
required this.surface,
required this.onSurface,
Color? surfaceDim,
Color? surfaceBright,
Color? surfaceContainerLowest,
Color? surfaceContainerLow,
Color? surfaceContainer,
Color? surfaceContainerHigh,
Color? surfaceContainerHighest,
Color? onSurfaceVariant,
Color? outline,
Color? outlineVariant,
Color? shadow,
Color? scrim,
Color? inverseSurface,
Color? onInverseSurface,
Color? inversePrimary,
Color? surfaceTint,
@Deprecated(
'Use surface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? background,
@Deprecated(
'Use onSurface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? onBackground,
@Deprecated(
'Use surfaceContainerHighest instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? surfaceVariant,
}) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer,
_primaryFixed = primaryFixed,
_primaryFixedDim = primaryFixedDim,
_onPrimaryFixed = onPrimaryFixed,
_onPrimaryFixedVariant = onPrimaryFixedVariant,
_secondaryContainer = secondaryContainer,
_onSecondaryContainer = onSecondaryContainer,
_secondaryFixed = secondaryFixed,
_secondaryFixedDim = secondaryFixedDim,
_onSecondaryFixed = onSecondaryFixed,
_onSecondaryFixedVariant = onSecondaryFixedVariant,
_tertiary = tertiary,
_onTertiary = onTertiary,
_tertiaryContainer = tertiaryContainer,
_onTertiaryContainer = onTertiaryContainer,
_tertiaryFixed = tertiaryFixed,
_tertiaryFixedDim = tertiaryFixedDim,
_onTertiaryFixed = onTertiaryFixed,
_onTertiaryFixedVariant = onTertiaryFixedVariant,
_errorContainer = errorContainer,
_onErrorContainer = onErrorContainer,
_surfaceDim = surfaceDim,
_surfaceBright = surfaceBright,
_surfaceContainerLowest = surfaceContainerLowest,
_surfaceContainerLow = surfaceContainerLow,
_surfaceContainer = surfaceContainer,
_surfaceContainerHigh = surfaceContainerHigh,
_surfaceContainerHighest = surfaceContainerHighest,
_onSurfaceVariant = onSurfaceVariant,
_outline = outline,
_outlineVariant = outlineVariant,
_shadow = shadow,
_scrim = scrim,
_inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary,
_surfaceTint = surfaceTint,
// DEPRECATED (newest deprecations at the bottom)
_background = background,
_onBackground = onBackground,
_surfaceVariant = surfaceVariant;
/// Generate a [ColorScheme] derived from the given `seedColor`.
///
/// Using the `seedColor` as a starting point, a set of tonal palettes are
/// constructed. By default, the tonal palettes are based on the Material 3
/// Color system and provide all of the [ColorScheme] colors. These colors are
/// designed to work well together and meet contrast requirements for
/// accessibility.
///
/// If any of the optional color parameters are non-null they will be
/// used in place of the generated colors for that field in the resulting
/// color scheme. This allows apps to override specific colors for their
/// needs.
///
/// Given the nature of the algorithm, the `seedColor` may not wind up as
/// one of the ColorScheme colors.
///
/// The `dynamicSchemeVariant` parameter creates different types of
/// [DynamicScheme]s, which are used to generate different styles of [ColorScheme]s.
/// By default, `dynamicSchemeVariant` is set to `tonalSpot`. A [ColorScheme]
/// constructed by `dynamicSchemeVariant.tonalSpot` has pastel palettes and
/// won't be too "colorful" even if the `seedColor` has a high chroma value.
/// If the resulting color scheme is too dark, consider setting `dynamicSchemeVariant`
/// to [DynamicSchemeVariant.fidelity], whose palettes match the seed color.
///
/// The `contrastLevel` parameter indicates the contrast level between color
/// pairs, such as [primary] and [onPrimary]. 0.0 is the default (normal);
/// -1.0 is the lowest; 1.0 is the highest. From Material Design guideline, the
/// medium and high contrast correspond to 0.5 and 1.0 respectively.
///
/// {@tool dartpad}
/// This sample shows how to use [ColorScheme.fromSeed] to create dynamic
/// color schemes with different [DynamicSchemeVariant]s and different
/// contrast level.
///
/// ** See code in examples/api/lib/material/color_scheme/color_scheme.0.dart **
/// {@end-tool}
///
/// See also:
///
/// * <https://m3.material.io/styles/color/the-color-system/color-roles>, the
/// Material 3 Color system specification.
/// * <https://pub.dev/packages/material_color_utilities>, the package
/// used to generate the tonal palettes needed for the scheme.
factory ColorScheme.fromSeed({
required Color seedColor,
Brightness brightness = Brightness.light,
DynamicSchemeVariant dynamicSchemeVariant = DynamicSchemeVariant.tonalSpot,
double contrastLevel = 0.0,
Color? primary,
Color? onPrimary,
Color? primaryContainer,
Color? onPrimaryContainer,
Color? primaryFixed,
Color? primaryFixedDim,
Color? onPrimaryFixed,
Color? onPrimaryFixedVariant,
Color? secondary,
Color? onSecondary,
Color? secondaryContainer,
Color? onSecondaryContainer,
Color? secondaryFixed,
Color? secondaryFixedDim,
Color? onSecondaryFixed,
Color? onSecondaryFixedVariant,
Color? tertiary,
Color? onTertiary,
Color? tertiaryContainer,
Color? onTertiaryContainer,
Color? tertiaryFixed,
Color? tertiaryFixedDim,
Color? onTertiaryFixed,
Color? onTertiaryFixedVariant,
Color? error,
Color? onError,
Color? errorContainer,
Color? onErrorContainer,
Color? outline,
Color? outlineVariant,
Color? surface,
Color? onSurface,
Color? surfaceDim,
Color? surfaceBright,
Color? surfaceContainerLowest,
Color? surfaceContainerLow,
Color? surfaceContainer,
Color? surfaceContainerHigh,
Color? surfaceContainerHighest,
Color? onSurfaceVariant,
Color? inverseSurface,
Color? onInverseSurface,
Color? inversePrimary,
Color? shadow,
Color? scrim,
Color? surfaceTint,
@Deprecated(
'Use surface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? background,
@Deprecated(
'Use onSurface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? onBackground,
@Deprecated(
'Use surfaceContainerHighest instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? surfaceVariant,
}) {
final DynamicScheme scheme = _buildDynamicScheme(
brightness,
seedColor,
dynamicSchemeVariant,
contrastLevel,
);
return ColorScheme(
primary: primary ?? Color(MaterialDynamicColors.primary.getArgb(scheme)),
onPrimary: onPrimary ?? Color(MaterialDynamicColors.onPrimary.getArgb(scheme)),
primaryContainer:
primaryContainer ?? Color(MaterialDynamicColors.primaryContainer.getArgb(scheme)),
onPrimaryContainer:
onPrimaryContainer ?? Color(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)),
primaryFixed: primaryFixed ?? Color(MaterialDynamicColors.primaryFixed.getArgb(scheme)),
primaryFixedDim:
primaryFixedDim ?? Color(MaterialDynamicColors.primaryFixedDim.getArgb(scheme)),
onPrimaryFixed: onPrimaryFixed ?? Color(MaterialDynamicColors.onPrimaryFixed.getArgb(scheme)),
onPrimaryFixedVariant:
onPrimaryFixedVariant ??
Color(MaterialDynamicColors.onPrimaryFixedVariant.getArgb(scheme)),
secondary: secondary ?? Color(MaterialDynamicColors.secondary.getArgb(scheme)),
onSecondary: onSecondary ?? Color(MaterialDynamicColors.onSecondary.getArgb(scheme)),
secondaryContainer:
secondaryContainer ?? Color(MaterialDynamicColors.secondaryContainer.getArgb(scheme)),
onSecondaryContainer:
onSecondaryContainer ?? Color(MaterialDynamicColors.onSecondaryContainer.getArgb(scheme)),
secondaryFixed: secondaryFixed ?? Color(MaterialDynamicColors.secondaryFixed.getArgb(scheme)),
secondaryFixedDim:
secondaryFixedDim ?? Color(MaterialDynamicColors.secondaryFixedDim.getArgb(scheme)),
onSecondaryFixed:
onSecondaryFixed ?? Color(MaterialDynamicColors.onSecondaryFixed.getArgb(scheme)),
onSecondaryFixedVariant:
onSecondaryFixedVariant ??
Color(MaterialDynamicColors.onSecondaryFixedVariant.getArgb(scheme)),
tertiary: tertiary ?? Color(MaterialDynamicColors.tertiary.getArgb(scheme)),
onTertiary: onTertiary ?? Color(MaterialDynamicColors.onTertiary.getArgb(scheme)),
tertiaryContainer:
tertiaryContainer ?? Color(MaterialDynamicColors.tertiaryContainer.getArgb(scheme)),
onTertiaryContainer:
onTertiaryContainer ?? Color(MaterialDynamicColors.onTertiaryContainer.getArgb(scheme)),
tertiaryFixed: tertiaryFixed ?? Color(MaterialDynamicColors.tertiaryFixed.getArgb(scheme)),
tertiaryFixedDim:
tertiaryFixedDim ?? Color(MaterialDynamicColors.tertiaryFixedDim.getArgb(scheme)),
onTertiaryFixed:
onTertiaryFixed ?? Color(MaterialDynamicColors.onTertiaryFixed.getArgb(scheme)),
onTertiaryFixedVariant:
onTertiaryFixedVariant ??
Color(MaterialDynamicColors.onTertiaryFixedVariant.getArgb(scheme)),
error: error ?? Color(MaterialDynamicColors.error.getArgb(scheme)),
onError: onError ?? Color(MaterialDynamicColors.onError.getArgb(scheme)),
errorContainer: errorContainer ?? Color(MaterialDynamicColors.errorContainer.getArgb(scheme)),
onErrorContainer:
onErrorContainer ?? Color(MaterialDynamicColors.onErrorContainer.getArgb(scheme)),
outline: outline ?? Color(MaterialDynamicColors.outline.getArgb(scheme)),
outlineVariant: outlineVariant ?? Color(MaterialDynamicColors.outlineVariant.getArgb(scheme)),
surface: surface ?? Color(MaterialDynamicColors.surface.getArgb(scheme)),
surfaceDim: surfaceDim ?? Color(MaterialDynamicColors.surfaceDim.getArgb(scheme)),
surfaceBright: surfaceBright ?? Color(MaterialDynamicColors.surfaceBright.getArgb(scheme)),
surfaceContainerLowest:
surfaceContainerLowest ??
Color(MaterialDynamicColors.surfaceContainerLowest.getArgb(scheme)),
surfaceContainerLow:
surfaceContainerLow ?? Color(MaterialDynamicColors.surfaceContainerLow.getArgb(scheme)),
surfaceContainer:
surfaceContainer ?? Color(MaterialDynamicColors.surfaceContainer.getArgb(scheme)),
surfaceContainerHigh:
surfaceContainerHigh ?? Color(MaterialDynamicColors.surfaceContainerHigh.getArgb(scheme)),
surfaceContainerHighest:
surfaceContainerHighest ??
Color(MaterialDynamicColors.surfaceContainerHighest.getArgb(scheme)),
onSurface: onSurface ?? Color(MaterialDynamicColors.onSurface.getArgb(scheme)),
onSurfaceVariant:
onSurfaceVariant ?? Color(MaterialDynamicColors.onSurfaceVariant.getArgb(scheme)),
inverseSurface: inverseSurface ?? Color(MaterialDynamicColors.inverseSurface.getArgb(scheme)),
onInverseSurface:
onInverseSurface ?? Color(MaterialDynamicColors.inverseOnSurface.getArgb(scheme)),
inversePrimary: inversePrimary ?? Color(MaterialDynamicColors.inversePrimary.getArgb(scheme)),
shadow: shadow ?? Color(MaterialDynamicColors.shadow.getArgb(scheme)),
scrim: scrim ?? Color(MaterialDynamicColors.scrim.getArgb(scheme)),
surfaceTint: surfaceTint ?? Color(MaterialDynamicColors.primary.getArgb(scheme)),
brightness: brightness,
// DEPRECATED (newest deprecations at the bottom)
background: background ?? Color(MaterialDynamicColors.background.getArgb(scheme)),
onBackground: onBackground ?? Color(MaterialDynamicColors.onBackground.getArgb(scheme)),
surfaceVariant: surfaceVariant ?? Color(MaterialDynamicColors.surfaceVariant.getArgb(scheme)),
);
}
/// Create a light ColorScheme based on a purple primary color that matches the
/// [baseline Material 2 color scheme](https://material.io/design/color/the-color-system.html#color-theme-creation).
///
/// This constructor shouldn't be used to update the Material 3 color scheme.
///
/// For Material 3, use [ColorScheme.fromSeed] to create a color scheme
/// from a single seed color based on the Material 3 color system.
///
/// {@tool snippet}
/// This example demonstrates how to create a color scheme similar to [ColorScheme.light]
/// using the [ColorScheme.fromSeed] constructor:
///
/// ```dart
/// colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xff6200ee)).copyWith(
/// primaryContainer: const Color(0xff6200ee),
/// onPrimaryContainer: Colors.white,
/// secondaryContainer: const Color(0xff03dac6),
/// onSecondaryContainer: Colors.black,
/// error: const Color(0xffb00020),
/// onError: Colors.white,
/// ),
/// ```
/// {@end-tool}
const ColorScheme.light({
this.brightness = Brightness.light,
this.primary = const Color(0xff6200ee),
this.onPrimary = Colors.white,
Color? primaryContainer,
Color? onPrimaryContainer,
Color? primaryFixed,
Color? primaryFixedDim,
Color? onPrimaryFixed,
Color? onPrimaryFixedVariant,
this.secondary = const Color(0xff03dac6),
this.onSecondary = Colors.black,
Color? secondaryContainer,
Color? onSecondaryContainer,
Color? secondaryFixed,
Color? secondaryFixedDim,
Color? onSecondaryFixed,
Color? onSecondaryFixedVariant,
Color? tertiary,
Color? onTertiary,
Color? tertiaryContainer,
Color? onTertiaryContainer,
Color? tertiaryFixed,
Color? tertiaryFixedDim,
Color? onTertiaryFixed,
Color? onTertiaryFixedVariant,
this.error = const Color(0xffb00020),
this.onError = Colors.white,
Color? errorContainer,
Color? onErrorContainer,
this.surface = Colors.white,
this.onSurface = Colors.black,
Color? surfaceDim,
Color? surfaceBright,
Color? surfaceContainerLowest,
Color? surfaceContainerLow,
Color? surfaceContainer,
Color? surfaceContainerHigh,
Color? surfaceContainerHighest,
Color? onSurfaceVariant,
Color? outline,
Color? outlineVariant,
Color? shadow,
Color? scrim,
Color? inverseSurface,
Color? onInverseSurface,
Color? inversePrimary,
Color? surfaceTint,
@Deprecated(
'Use surface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? background = Colors.white,
@Deprecated(
'Use onSurface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? onBackground = Colors.black,
@Deprecated(
'Use surfaceContainerHighest instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? surfaceVariant,
}) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer,
_primaryFixed = primaryFixed,
_primaryFixedDim = primaryFixedDim,
_onPrimaryFixed = onPrimaryFixed,
_onPrimaryFixedVariant = onPrimaryFixedVariant,
_secondaryContainer = secondaryContainer,
_onSecondaryContainer = onSecondaryContainer,
_secondaryFixed = secondaryFixed,
_secondaryFixedDim = secondaryFixedDim,
_onSecondaryFixed = onSecondaryFixed,
_onSecondaryFixedVariant = onSecondaryFixedVariant,
_tertiary = tertiary,
_onTertiary = onTertiary,
_tertiaryContainer = tertiaryContainer,
_onTertiaryContainer = onTertiaryContainer,
_tertiaryFixed = tertiaryFixed,
_tertiaryFixedDim = tertiaryFixedDim,
_onTertiaryFixed = onTertiaryFixed,
_onTertiaryFixedVariant = onTertiaryFixedVariant,
_errorContainer = errorContainer,
_onErrorContainer = onErrorContainer,
_surfaceDim = surfaceDim,
_surfaceBright = surfaceBright,
_surfaceContainerLowest = surfaceContainerLowest,
_surfaceContainerLow = surfaceContainerLow,
_surfaceContainer = surfaceContainer,
_surfaceContainerHigh = surfaceContainerHigh,
_surfaceContainerHighest = surfaceContainerHighest,
_onSurfaceVariant = onSurfaceVariant,
_outline = outline,
_outlineVariant = outlineVariant,
_shadow = shadow,
_scrim = scrim,
_inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary,
_surfaceTint = surfaceTint,
// DEPRECATED (newest deprecations at the bottom)
_background = background,
_onBackground = onBackground,
_surfaceVariant = surfaceVariant;
/// Create the dark color scheme that matches the
/// [baseline Material 2 color scheme](https://material.io/design/color/dark-theme.html#ui-application).
///
/// This constructor shouldn't be used to update the Material 3 color scheme.
///
/// For Material 3, use [ColorScheme.fromSeed] to create a color scheme
/// from a single seed color based on the Material 3 color system.
/// Override the `brightness` property of [ColorScheme.fromSeed] to create a
/// dark color scheme.
///
/// {@tool snippet}
/// This example demonstrates how to create a color scheme similar to [ColorScheme.dark]
/// using the [ColorScheme.fromSeed] constructor:
///
/// ```dart
/// colorScheme: ColorScheme.fromSeed(
/// seedColor: const Color(0xffbb86fc),
/// brightness: Brightness.dark,
/// ).copyWith(
/// primaryContainer: const Color(0xffbb86fc),
/// onPrimaryContainer: Colors.black,
/// secondaryContainer: const Color(0xff03dac6),
/// onSecondaryContainer: Colors.black,
/// error: const Color(0xffcf6679),
/// onError: Colors.black,
/// ),
/// ```
/// {@end-tool}
const ColorScheme.dark({
this.brightness = Brightness.dark,
this.primary = const Color(0xffbb86fc),
this.onPrimary = Colors.black,
Color? primaryContainer,
Color? onPrimaryContainer,
Color? primaryFixed,
Color? primaryFixedDim,
Color? onPrimaryFixed,
Color? onPrimaryFixedVariant,
this.secondary = const Color(0xff03dac6),
this.onSecondary = Colors.black,
Color? secondaryContainer,
Color? onSecondaryContainer,
Color? secondaryFixed,
Color? secondaryFixedDim,
Color? onSecondaryFixed,
Color? onSecondaryFixedVariant,
Color? tertiary,
Color? onTertiary,
Color? tertiaryContainer,
Color? onTertiaryContainer,
Color? tertiaryFixed,
Color? tertiaryFixedDim,
Color? onTertiaryFixed,
Color? onTertiaryFixedVariant,
this.error = const Color(0xffcf6679),
this.onError = Colors.black,
Color? errorContainer,
Color? onErrorContainer,
this.surface = const Color(0xff121212),
this.onSurface = Colors.white,
Color? surfaceDim,
Color? surfaceBright,
Color? surfaceContainerLowest,
Color? surfaceContainerLow,
Color? surfaceContainer,
Color? surfaceContainerHigh,
Color? surfaceContainerHighest,
Color? onSurfaceVariant,
Color? outline,
Color? outlineVariant,
Color? shadow,
Color? scrim,
Color? inverseSurface,
Color? onInverseSurface,
Color? inversePrimary,
Color? surfaceTint,
@Deprecated(
'Use surface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? background = const Color(0xff121212),
@Deprecated(
'Use onSurface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? onBackground = Colors.white,
@Deprecated(
'Use surfaceContainerHighest instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? surfaceVariant,
}) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer,
_primaryFixed = primaryFixed,
_primaryFixedDim = primaryFixedDim,
_onPrimaryFixed = onPrimaryFixed,
_onPrimaryFixedVariant = onPrimaryFixedVariant,
_secondaryContainer = secondaryContainer,
_onSecondaryContainer = onSecondaryContainer,
_secondaryFixed = secondaryFixed,
_secondaryFixedDim = secondaryFixedDim,
_onSecondaryFixed = onSecondaryFixed,
_onSecondaryFixedVariant = onSecondaryFixedVariant,
_tertiary = tertiary,
_onTertiary = onTertiary,
_tertiaryContainer = tertiaryContainer,
_onTertiaryContainer = onTertiaryContainer,
_tertiaryFixed = tertiaryFixed,
_tertiaryFixedDim = tertiaryFixedDim,
_onTertiaryFixed = onTertiaryFixed,
_onTertiaryFixedVariant = onTertiaryFixedVariant,
_errorContainer = errorContainer,
_onErrorContainer = onErrorContainer,
_surfaceDim = surfaceDim,
_surfaceBright = surfaceBright,
_surfaceContainerLowest = surfaceContainerLowest,
_surfaceContainerLow = surfaceContainerLow,
_surfaceContainer = surfaceContainer,
_surfaceContainerHigh = surfaceContainerHigh,
_surfaceContainerHighest = surfaceContainerHighest,
_onSurfaceVariant = onSurfaceVariant,
_outline = outline,
_outlineVariant = outlineVariant,
_shadow = shadow,
_scrim = scrim,
_inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary,
_surfaceTint = surfaceTint,
// DEPRECATED (newest deprecations at the bottom)
_background = background,
_onBackground = onBackground,
_surfaceVariant = surfaceVariant;
/// Create a high contrast ColorScheme based on a purple primary color that
/// matches the [baseline Material 2 color scheme](https://material.io/design/color/the-color-system.html#color-theme-creation).
///
/// This constructor shouldn't be used to update the Material 3 color scheme.
///
/// For Material 3, use [ColorScheme.fromSeed] to create a color scheme
/// from a single seed color based on the Material 3 color system. To create a
/// high-contrast color scheme, set `contrastLevel` to 1.0.
///
/// {@tool snippet}
/// This example demonstrates how to create a color scheme similar to [ColorScheme.highContrastLight]
/// using the [ColorScheme.fromSeed] constructor:
///
/// ```dart
/// colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xff0000ba)).copyWith(
/// primaryContainer: const Color(0xff0000ba),
/// onPrimaryContainer: Colors.white,
/// secondaryContainer: const Color(0xff66fff9),
/// onSecondaryContainer: Colors.black,
/// error: const Color(0xff790000),
/// onError: Colors.white,
/// ),
/// ```
/// {@end-tool}
const ColorScheme.highContrastLight({
this.brightness = Brightness.light,
this.primary = const Color(0xff0000ba),
this.onPrimary = Colors.white,
Color? primaryContainer,
Color? onPrimaryContainer,
Color? primaryFixed,
Color? primaryFixedDim,
Color? onPrimaryFixed,
Color? onPrimaryFixedVariant,
this.secondary = const Color(0xff66fff9),
this.onSecondary = Colors.black,
Color? secondaryContainer,
Color? onSecondaryContainer,
Color? secondaryFixed,
Color? secondaryFixedDim,
Color? onSecondaryFixed,
Color? onSecondaryFixedVariant,
Color? tertiary,
Color? onTertiary,
Color? tertiaryContainer,
Color? onTertiaryContainer,
Color? tertiaryFixed,
Color? tertiaryFixedDim,
Color? onTertiaryFixed,
Color? onTertiaryFixedVariant,
this.error = const Color(0xff790000),
this.onError = Colors.white,
Color? errorContainer,
Color? onErrorContainer,
this.surface = Colors.white,
this.onSurface = Colors.black,
Color? surfaceDim,
Color? surfaceBright,
Color? surfaceContainerLowest,
Color? surfaceContainerLow,
Color? surfaceContainer,
Color? surfaceContainerHigh,
Color? surfaceContainerHighest,
Color? onSurfaceVariant,
Color? outline,
Color? outlineVariant,
Color? shadow,
Color? scrim,
Color? inverseSurface,
Color? onInverseSurface,
Color? inversePrimary,
Color? surfaceTint,
@Deprecated(
'Use surface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? background = Colors.white,
@Deprecated(
'Use onSurface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? onBackground = Colors.black,
@Deprecated(
'Use surfaceContainerHighest instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? surfaceVariant,
}) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer,
_primaryFixed = primaryFixed,
_primaryFixedDim = primaryFixedDim,
_onPrimaryFixed = onPrimaryFixed,
_onPrimaryFixedVariant = onPrimaryFixedVariant,
_secondaryContainer = secondaryContainer,
_onSecondaryContainer = onSecondaryContainer,
_secondaryFixed = secondaryFixed,
_secondaryFixedDim = secondaryFixedDim,
_onSecondaryFixed = onSecondaryFixed,
_onSecondaryFixedVariant = onSecondaryFixedVariant,
_tertiary = tertiary,
_onTertiary = onTertiary,
_tertiaryContainer = tertiaryContainer,
_onTertiaryContainer = onTertiaryContainer,
_tertiaryFixed = tertiaryFixed,
_tertiaryFixedDim = tertiaryFixedDim,
_onTertiaryFixed = onTertiaryFixed,
_onTertiaryFixedVariant = onTertiaryFixedVariant,
_errorContainer = errorContainer,
_onErrorContainer = onErrorContainer,
_surfaceDim = surfaceDim,
_surfaceBright = surfaceBright,
_surfaceContainerLowest = surfaceContainerLowest,
_surfaceContainerLow = surfaceContainerLow,
_surfaceContainer = surfaceContainer,
_surfaceContainerHigh = surfaceContainerHigh,
_surfaceContainerHighest = surfaceContainerHighest,
_onSurfaceVariant = onSurfaceVariant,
_outline = outline,
_outlineVariant = outlineVariant,
_shadow = shadow,
_scrim = scrim,
_inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary,
_surfaceTint = surfaceTint,
// DEPRECATED (newest deprecations at the bottom)
_background = background,
_onBackground = onBackground,
_surfaceVariant = surfaceVariant;
/// Create a high contrast ColorScheme based on the dark
/// [baseline Material 2 color scheme](https://material.io/design/color/dark-theme.html#ui-application).
///
/// This constructor shouldn't be used to update the Material 3 color scheme.
///
/// For Material 3, use [ColorScheme.fromSeed] to create a color scheme
/// from a single seed color based on the Material 3 color system.
/// Override the `brightness` property of [ColorScheme.fromSeed] to create a
/// dark color scheme. To create a high-contrast color scheme, set
/// `contrastLevel` to 1.0.
///
/// {@tool snippet}
/// This example demonstrates how to create a color scheme similar to [ColorScheme.highContrastDark]
/// using the [ColorScheme.fromSeed] constructor:
///
/// ```dart
/// colorScheme: ColorScheme.fromSeed(
/// seedColor: const Color(0xffefb7ff),
/// brightness: Brightness.dark,
/// ).copyWith(
/// primaryContainer: const Color(0xffefb7ff),
/// onPrimaryContainer: Colors.black,
/// secondaryContainer: const Color(0xff66fff9),
/// onSecondaryContainer: Colors.black,
/// error: const Color(0xff9b374d),
/// onError: Colors.white,
/// ),
/// ```
/// {@end-tool}
const ColorScheme.highContrastDark({
this.brightness = Brightness.dark,
this.primary = const Color(0xffefb7ff),
this.onPrimary = Colors.black,
Color? primaryContainer,
Color? onPrimaryContainer,
Color? primaryFixed,
Color? primaryFixedDim,
Color? onPrimaryFixed,
Color? onPrimaryFixedVariant,
this.secondary = const Color(0xff66fff9),
this.onSecondary = Colors.black,
Color? secondaryContainer,
Color? onSecondaryContainer,
Color? secondaryFixed,
Color? secondaryFixedDim,
Color? onSecondaryFixed,
Color? onSecondaryFixedVariant,
Color? tertiary,
Color? onTertiary,
Color? tertiaryContainer,
Color? onTertiaryContainer,
Color? tertiaryFixed,
Color? tertiaryFixedDim,
Color? onTertiaryFixed,
Color? onTertiaryFixedVariant,
this.error = const Color(0xff9b374d),
this.onError = Colors.black,
Color? errorContainer,
Color? onErrorContainer,
this.surface = const Color(0xff121212),
this.onSurface = Colors.white,
Color? surfaceDim,
Color? surfaceBright,
Color? surfaceContainerLowest,
Color? surfaceContainerLow,
Color? surfaceContainer,
Color? surfaceContainerHigh,
Color? surfaceContainerHighest,
Color? onSurfaceVariant,
Color? outline,
Color? outlineVariant,
Color? shadow,
Color? scrim,
Color? inverseSurface,
Color? onInverseSurface,
Color? inversePrimary,
Color? surfaceTint,
@Deprecated(
'Use surface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? background = const Color(0xff121212),
@Deprecated(
'Use onSurface instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? onBackground = Colors.white,
@Deprecated(
'Use surfaceContainerHighest instead. '
'This feature was deprecated after v3.18.0-0.1.pre.',
)
Color? surfaceVariant,
}) : _primaryContainer = primaryContainer,
_onPrimaryContainer = onPrimaryContainer,
_primaryFixed = primaryFixed,
_primaryFixedDim = primaryFixedDim,
_onPrimaryFixed = onPrimaryFixed,
_onPrimaryFixedVariant = onPrimaryFixedVariant,
_secondaryContainer = secondaryContainer,
_onSecondaryContainer = onSecondaryContainer,
_secondaryFixed = secondaryFixed,
_secondaryFixedDim = secondaryFixedDim,
_onSecondaryFixed = onSecondaryFixed,
_onSecondaryFixedVariant = onSecondaryFixedVariant,
_tertiary = tertiary,
_onTertiary = onTertiary,
_tertiaryContainer = tertiaryContainer,
_onTertiaryContainer = onTertiaryContainer,
_tertiaryFixed = tertiaryFixed,
_tertiaryFixedDim = tertiaryFixedDim,
_onTertiaryFixed = onTertiaryFixed,
_onTertiaryFixedVariant = onTertiaryFixedVariant,
_errorContainer = errorContainer,
_onErrorContainer = onErrorContainer,
_surfaceDim = surfaceDim,
_surfaceBright = surfaceBright,
_surfaceContainerLowest = surfaceContainerLowest,
_surfaceContainerLow = surfaceContainerLow,
_surfaceContainer = surfaceContainer,
_surfaceContainerHigh = surfaceContainerHigh,
_surfaceContainerHighest = surfaceContainerHighest,
_onSurfaceVariant = onSurfaceVariant,
_outline = outline,
_outlineVariant = outlineVariant,
_shadow = shadow,
_scrim = scrim,
_inverseSurface = inverseSurface,
_onInverseSurface = onInverseSurface,
_inversePrimary = inversePrimary,
_surfaceTint = surfaceTint,
// DEPRECATED (newest deprecations at the bottom)
_background = background,
_onBackground = onBackground,
_surfaceVariant = surfaceVariant;
/// Creates a color scheme from a [MaterialColor] swatch.
///
/// In Material 3, this constructor is ignored by [ThemeData] when creating
/// its default color scheme. Instead, [ThemeData] uses [ColorScheme.fromSeed]
/// to create its default color scheme. This constructor shouldn't be used
/// to update the Material 3 color scheme. It will be phased out gradually;
/// see https://github.com/flutter/flutter/issues/120064 for more details.
///