-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Expand file tree
/
Copy pathcolors.dart
More file actions
1287 lines (1184 loc) · 54.2 KB
/
Copy pathcolors.dart
File metadata and controls
1287 lines (1184 loc) · 54.2 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 'package:flutter/material.dart';
///
/// @docImport 'button.dart';
/// @docImport 'nav_bar.dart';
library;
import 'dart:ui' show Brightness, Color, ColorSpace;
import '../../foundation.dart';
import '../widgets/basic.dart';
import '../widgets/framework.dart';
import '../widgets/media_query.dart';
import 'interface_level.dart';
import 'theme.dart';
// Examples can assume:
// late Widget child;
// late BuildContext context;
/// A palette of [Color] constants that describe colors commonly used when
/// matching the iOS platform aesthetics.
///
/// ## Color palettes
///
/// ### Basic Colors
/// 
///
/// ### Active Colors
/// 
///
/// ### System Colors
/// 
/// 
/// 
///
/// ### Label Colors
/// 
///
/// ### Background Colors
/// 
///
abstract final class CupertinoColors {
/// iOS 13's default blue color. Used to indicate active elements such as
/// buttons, selected tabs and your own chat bubbles.
///
/// This is SystemBlue in the iOS palette.
static const CupertinoDynamicColor activeBlue = systemBlue;
/// iOS 13's default green color. Used to indicate active accents such as
/// the switch in its on state and some accent buttons such as the call button
/// and Apple Map's 'Go' button.
///
/// This is SystemGreen in the iOS palette.
static const CupertinoDynamicColor activeGreen = systemGreen;
/// iOS 13's orange color.
///
/// This is SystemOrange in the iOS palette.
static const CupertinoDynamicColor activeOrange = systemOrange;
/// Opaque white color. Used for backgrounds and fonts against dark backgrounds.
///
/// This is SystemWhiteColor in the iOS palette.
///
/// See also:
///
/// * [Colors.white], the same color, in the Material Design palette.
/// * [black], opaque black in the [CupertinoColors] palette.
static const Color white = Color(0xFFFFFFFF);
/// Opaque black color. Used for texts against light backgrounds.
///
/// This is SystemBlackColor in the iOS palette.
///
/// See also:
///
/// * [Colors.black], the same color, in the Material Design palette.
/// * [white], opaque white in the [CupertinoColors] palette.
static const Color black = Color(0xFF000000);
/// A fully-transparent color, completely invisible.
///
/// See also:
///
/// * [Colors.transparent], the same color, in the Material Design palette.
static const Color transparent = Color(0x00000000);
/// Used in iOS 10 for light background fills such as the chat bubble background.
///
/// This is SystemLightGrayColor in the iOS palette.
static const Color lightBackgroundGray = Color(0xFFE5E5EA);
/// Used in iOS 12 for very light background fills in tables between cell groups.
///
/// This is SystemExtraLightGrayColor in the iOS palette.
static const Color extraLightBackgroundGray = Color(0xFFEFEFF4);
/// Used in iOS 12 for very dark background fills in tables between cell groups
/// in dark mode.
// Value derived from screenshot from the dark themed Apple Watch app.
static const Color darkBackgroundGray = Color(0xFF171717);
/// Used in iOS 13 for unselected selectables such as tab bar items in their
/// inactive state or de-emphasized subtitles and details text.
///
/// Not the same grey as disabled buttons etc.
///
/// This is the disabled color in the iOS palette.
static const CupertinoDynamicColor inactiveGray = CupertinoDynamicColor.withBrightness(
debugLabel: 'inactiveGray',
color: Color(0xFF999999),
darkColor: Color(0xFF757575),
);
/// Used for iOS 13 for destructive actions such as the delete actions in
/// table view cells and dialogs.
///
/// Not the same red as the camera shutter or springboard icon notifications
/// or the foreground red theme in various native apps such as HealthKit.
///
/// This is SystemRed in the iOS palette.
static const CupertinoDynamicColor destructiveRed = systemRed;
/// A blue color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemBlue](https://developer.apple.com/documentation/uikit/uicolor/3173141-systemblue),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemBlue = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemBlue',
color: Color.fromARGB(255, 0, 122, 255),
darkColor: Color.fromARGB(255, 10, 132, 255),
highContrastColor: Color.fromARGB(255, 0, 64, 221),
darkHighContrastColor: Color.fromARGB(255, 64, 156, 255),
);
/// A green color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemGreen](https://developer.apple.com/documentation/uikit/uicolor/3173144-systemgreen),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGreen = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGreen',
color: Color.fromARGB(255, 52, 199, 89),
darkColor: Color.fromARGB(255, 48, 209, 88),
highContrastColor: Color.fromARGB(255, 36, 138, 61),
darkHighContrastColor: Color.fromARGB(255, 48, 219, 91),
);
/// A mint color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemMint](https://developer.apple.com/documentation/uikit/uicolor/3852741-systemmint),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemMint = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemMint',
color: Color.fromARGB(255, 0, 199, 190),
darkColor: Color.fromARGB(255, 99, 230, 226),
highContrastColor: Color.fromARGB(255, 12, 129, 123),
darkHighContrastColor: Color.fromARGB(255, 102, 212, 207),
);
/// An indigo color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemIndigo](https://developer.apple.com/documentation/uikit/uicolor/3173146-systemindigo),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemIndigo = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemIndigo',
color: Color.fromARGB(255, 88, 86, 214),
darkColor: Color.fromARGB(255, 94, 92, 230),
highContrastColor: Color.fromARGB(255, 54, 52, 163),
darkHighContrastColor: Color.fromARGB(255, 125, 122, 255),
);
/// An orange color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemOrange](https://developer.apple.com/documentation/uikit/uicolor/3173147-systemorange),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemOrange = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemOrange',
color: Color.fromARGB(255, 255, 149, 0),
darkColor: Color.fromARGB(255, 255, 159, 10),
highContrastColor: Color.fromARGB(255, 201, 52, 0),
darkHighContrastColor: Color.fromARGB(255, 255, 179, 64),
);
/// A pink color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemPink](https://developer.apple.com/documentation/uikit/uicolor/3173148-systempink),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemPink = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemPink',
color: Color.fromARGB(255, 255, 45, 85),
darkColor: Color.fromARGB(255, 255, 55, 95),
highContrastColor: Color.fromARGB(255, 211, 15, 69),
darkHighContrastColor: Color.fromARGB(255, 255, 100, 130),
);
/// A brown color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemBrown](https://developer.apple.com/documentation/uikit/uicolor/3173142-systembrown),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemBrown = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemBrown',
color: Color.fromARGB(255, 162, 132, 94),
darkColor: Color.fromARGB(255, 172, 142, 104),
highContrastColor: Color.fromARGB(255, 127, 101, 69),
darkHighContrastColor: Color.fromARGB(255, 181, 148, 105),
);
/// A purple color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemPurple](https://developer.apple.com/documentation/uikit/uicolor/3173149-systempurple),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemPurple = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemPurple',
color: Color.fromARGB(255, 175, 82, 222),
darkColor: Color.fromARGB(255, 191, 90, 242),
highContrastColor: Color.fromARGB(255, 137, 68, 171),
darkHighContrastColor: Color.fromARGB(255, 218, 143, 255),
);
/// A red color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemRed](https://developer.apple.com/documentation/uikit/uicolor/3173150-systemred),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemRed = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemRed',
color: Color.fromARGB(255, 255, 59, 48),
darkColor: Color.fromARGB(255, 255, 69, 58),
highContrastColor: Color.fromARGB(255, 215, 0, 21),
darkHighContrastColor: Color.fromARGB(255, 255, 105, 97),
);
/// A teal color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemTeal](https://developer.apple.com/documentation/uikit/uicolor/3173151-systemteal),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemTeal = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemTeal',
color: Color.fromARGB(255, 90, 200, 250),
darkColor: Color.fromARGB(255, 100, 210, 255),
highContrastColor: Color.fromARGB(255, 0, 113, 164),
darkHighContrastColor: Color.fromARGB(255, 112, 215, 255),
);
/// A cyan color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemCyan](https://developer.apple.com/documentation/uikit/uicolor/3852740-systemcyan),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemCyan = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemCyan',
color: Color.fromARGB(255, 50, 173, 230),
darkColor: Color.fromARGB(255, 100, 210, 255),
highContrastColor: Color.fromARGB(255, 0, 113, 164),
darkHighContrastColor: Color.fromARGB(255, 112, 215, 255),
);
/// A yellow color that can adapt to the given [BuildContext].
///
/// See also:
///
/// * [UIColor.systemYellow](https://developer.apple.com/documentation/uikit/uicolor/3173152-systemyellow),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemYellow = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemYellow',
color: Color.fromARGB(255, 255, 204, 0),
darkColor: Color.fromARGB(255, 255, 214, 10),
highContrastColor: Color.fromARGB(255, 160, 90, 0),
darkHighContrastColor: Color.fromARGB(255, 255, 212, 38),
);
/// The base grey color.
///
/// See also:
///
/// * [UIColor.systemGray](https://developer.apple.com/documentation/uikit/uicolor/3173143-systemgray),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey',
color: Color.fromARGB(255, 142, 142, 147),
darkColor: Color.fromARGB(255, 142, 142, 147),
highContrastColor: Color.fromARGB(255, 108, 108, 112),
darkHighContrastColor: Color.fromARGB(255, 174, 174, 178),
);
/// A second-level shade of grey.
///
/// See also:
///
/// * [UIColor.systemGray2](https://developer.apple.com/documentation/uikit/uicolor/3255071-systemgray2),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey2 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey2',
color: Color.fromARGB(255, 174, 174, 178),
darkColor: Color.fromARGB(255, 99, 99, 102),
highContrastColor: Color.fromARGB(255, 142, 142, 147),
darkHighContrastColor: Color.fromARGB(255, 124, 124, 128),
);
/// A third-level shade of grey.
///
/// See also:
///
/// * [UIColor.systemGray3](https://developer.apple.com/documentation/uikit/uicolor/3255072-systemgray3),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey3 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey3',
color: Color.fromARGB(255, 199, 199, 204),
darkColor: Color.fromARGB(255, 72, 72, 74),
highContrastColor: Color.fromARGB(255, 174, 174, 178),
darkHighContrastColor: Color.fromARGB(255, 84, 84, 86),
);
/// A fourth-level shade of grey.
///
/// See also:
///
/// * [UIColor.systemGray4](https://developer.apple.com/documentation/uikit/uicolor/3255073-systemgray4),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey4 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey4',
color: Color.fromARGB(255, 209, 209, 214),
darkColor: Color.fromARGB(255, 58, 58, 60),
highContrastColor: Color.fromARGB(255, 188, 188, 192),
darkHighContrastColor: Color.fromARGB(255, 68, 68, 70),
);
/// A fifth-level shade of grey.
///
/// See also:
///
/// * [UIColor.systemGray5](https://developer.apple.com/documentation/uikit/uicolor/3255074-systemgray5),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey5 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey5',
color: Color.fromARGB(255, 229, 229, 234),
darkColor: Color.fromARGB(255, 44, 44, 46),
highContrastColor: Color.fromARGB(255, 216, 216, 220),
darkHighContrastColor: Color.fromARGB(255, 54, 54, 56),
);
/// A sixth-level shade of grey.
///
/// See also:
///
/// * [UIColor.systemGray6](https://developer.apple.com/documentation/uikit/uicolor/3255075-systemgray6),
/// the `UIKit` equivalent.
static const CupertinoDynamicColor systemGrey6 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: 'systemGrey6',
color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 28, 28, 30),
highContrastColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastColor: Color.fromARGB(255, 36, 36, 38),
);
/// The color for text labels containing primary content, equivalent to
/// [UIColor.label](https://developer.apple.com/documentation/uikit/uicolor/3173131-label).
static const CupertinoDynamicColor label = CupertinoDynamicColor(
debugLabel: 'label',
color: Color.fromARGB(255, 0, 0, 0),
darkColor: Color.fromARGB(255, 255, 255, 255),
highContrastColor: Color.fromARGB(255, 0, 0, 0),
darkHighContrastColor: Color.fromARGB(255, 255, 255, 255),
elevatedColor: Color.fromARGB(255, 0, 0, 0),
darkElevatedColor: Color.fromARGB(255, 255, 255, 255),
highContrastElevatedColor: Color.fromARGB(255, 0, 0, 0),
darkHighContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
);
/// The color for text labels containing secondary content, equivalent to
/// [UIColor.secondaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173136-secondarylabel).
static const CupertinoDynamicColor secondaryLabel = CupertinoDynamicColor(
debugLabel: 'secondaryLabel',
color: Color.fromARGB(153, 60, 60, 67),
darkColor: Color.fromARGB(153, 235, 235, 245),
highContrastColor: Color.fromARGB(173, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(173, 235, 235, 245),
elevatedColor: Color.fromARGB(153, 60, 60, 67),
darkElevatedColor: Color.fromARGB(153, 235, 235, 245),
highContrastElevatedColor: Color.fromARGB(173, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(173, 235, 235, 245),
);
/// The color for text labels containing tertiary content, equivalent to
/// [UIColor.tertiaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173153-tertiarylabel).
static const CupertinoDynamicColor tertiaryLabel = CupertinoDynamicColor(
debugLabel: 'tertiaryLabel',
color: Color.fromARGB(76, 60, 60, 67),
darkColor: Color.fromARGB(76, 235, 235, 245),
highContrastColor: Color.fromARGB(96, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(96, 235, 235, 245),
elevatedColor: Color.fromARGB(76, 60, 60, 67),
darkElevatedColor: Color.fromARGB(76, 235, 235, 245),
highContrastElevatedColor: Color.fromARGB(96, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(96, 235, 235, 245),
);
/// The color for text labels containing quaternary content, equivalent to
/// [UIColor.quaternaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173135-quaternarylabel).
static const CupertinoDynamicColor quaternaryLabel = CupertinoDynamicColor(
debugLabel: 'quaternaryLabel',
color: Color.fromARGB(45, 60, 60, 67),
darkColor: Color.fromARGB(40, 235, 235, 245),
highContrastColor: Color.fromARGB(66, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(61, 235, 235, 245),
elevatedColor: Color.fromARGB(45, 60, 60, 67),
darkElevatedColor: Color.fromARGB(40, 235, 235, 245),
highContrastElevatedColor: Color.fromARGB(66, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(61, 235, 235, 245),
);
/// An overlay fill color for thin and small shapes, equivalent to
/// [UIColor.systemFill](https://developer.apple.com/documentation/uikit/uicolor/3255070-systemfill).
static const CupertinoDynamicColor systemFill = CupertinoDynamicColor(
debugLabel: 'systemFill',
color: Color.fromARGB(51, 120, 120, 128),
darkColor: Color.fromARGB(91, 120, 120, 128),
highContrastColor: Color.fromARGB(71, 120, 120, 128),
darkHighContrastColor: Color.fromARGB(112, 120, 120, 128),
elevatedColor: Color.fromARGB(51, 120, 120, 128),
darkElevatedColor: Color.fromARGB(91, 120, 120, 128),
highContrastElevatedColor: Color.fromARGB(71, 120, 120, 128),
darkHighContrastElevatedColor: Color.fromARGB(112, 120, 120, 128),
);
/// An overlay fill color for medium-size shapes, equivalent to
/// [UIColor.secondarySystemFill](https://developer.apple.com/documentation/uikit/uicolor/3255069-secondarysystemfill).
static const CupertinoDynamicColor secondarySystemFill = CupertinoDynamicColor(
debugLabel: 'secondarySystemFill',
color: Color.fromARGB(40, 120, 120, 128),
darkColor: Color.fromARGB(81, 120, 120, 128),
highContrastColor: Color.fromARGB(61, 120, 120, 128),
darkHighContrastColor: Color.fromARGB(102, 120, 120, 128),
elevatedColor: Color.fromARGB(40, 120, 120, 128),
darkElevatedColor: Color.fromARGB(81, 120, 120, 128),
highContrastElevatedColor: Color.fromARGB(61, 120, 120, 128),
darkHighContrastElevatedColor: Color.fromARGB(102, 120, 120, 128),
);
/// An overlay fill color for large shapes, equivalent to
/// [UIColor.tertiarySystemFill](https://developer.apple.com/documentation/uikit/uicolor/3255076-tertiarysystemfill).
static const CupertinoDynamicColor tertiarySystemFill = CupertinoDynamicColor(
debugLabel: 'tertiarySystemFill',
color: Color.fromARGB(30, 118, 118, 128),
darkColor: Color.fromARGB(61, 118, 118, 128),
highContrastColor: Color.fromARGB(51, 118, 118, 128),
darkHighContrastColor: Color.fromARGB(81, 118, 118, 128),
elevatedColor: Color.fromARGB(30, 118, 118, 128),
darkElevatedColor: Color.fromARGB(61, 118, 118, 128),
highContrastElevatedColor: Color.fromARGB(51, 118, 118, 128),
darkHighContrastElevatedColor: Color.fromARGB(81, 118, 118, 128),
);
/// An overlay fill color for large areas containing complex content, equivalent
/// to [UIColor.quaternarySystemFill](https://developer.apple.com/documentation/uikit/uicolor/3255068-quaternarysystemfill).
static const CupertinoDynamicColor quaternarySystemFill = CupertinoDynamicColor(
debugLabel: 'quaternarySystemFill',
color: Color.fromARGB(20, 116, 116, 128),
darkColor: Color.fromARGB(45, 118, 118, 128),
highContrastColor: Color.fromARGB(40, 116, 116, 128),
darkHighContrastColor: Color.fromARGB(66, 118, 118, 128),
elevatedColor: Color.fromARGB(20, 116, 116, 128),
darkElevatedColor: Color.fromARGB(45, 118, 118, 128),
highContrastElevatedColor: Color.fromARGB(40, 116, 116, 128),
darkHighContrastElevatedColor: Color.fromARGB(66, 118, 118, 128),
);
/// The color for placeholder text in controls or text views, equivalent to
/// [UIColor.placeholderText](https://developer.apple.com/documentation/uikit/uicolor/3173134-placeholdertext).
static const CupertinoDynamicColor placeholderText = CupertinoDynamicColor(
debugLabel: 'placeholderText',
color: Color.fromARGB(76, 60, 60, 67),
darkColor: Color.fromARGB(76, 235, 235, 245),
highContrastColor: Color.fromARGB(96, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(96, 235, 235, 245),
elevatedColor: Color.fromARGB(76, 60, 60, 67),
darkElevatedColor: Color.fromARGB(76, 235, 235, 245),
highContrastElevatedColor: Color.fromARGB(96, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(96, 235, 235, 245),
);
/// The color for the main background of your interface, equivalent to
/// [UIColor.systemBackground](https://developer.apple.com/documentation/uikit/uicolor/3173140-systembackground).
///
/// Typically used for designs that have a white primary background in a light environment.
static const CupertinoDynamicColor systemBackground = CupertinoDynamicColor(
debugLabel: 'systemBackground',
color: Color.fromARGB(255, 255, 255, 255),
darkColor: Color.fromARGB(255, 0, 0, 0),
highContrastColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastColor: Color.fromARGB(255, 0, 0, 0),
elevatedColor: Color.fromARGB(255, 255, 255, 255),
darkElevatedColor: Color.fromARGB(255, 28, 28, 30),
highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastElevatedColor: Color.fromARGB(255, 36, 36, 38),
);
/// The color for content layered on top of the main background, equivalent to
/// [UIColor.secondarySystemBackground](https://developer.apple.com/documentation/uikit/uicolor/3173137-secondarysystembackground).
///
/// Typically used for designs that have a white primary background in a light environment.
static const CupertinoDynamicColor secondarySystemBackground = CupertinoDynamicColor(
debugLabel: 'secondarySystemBackground',
color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 28, 28, 30),
highContrastColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastColor: Color.fromARGB(255, 36, 36, 38),
elevatedColor: Color.fromARGB(255, 242, 242, 247),
darkElevatedColor: Color.fromARGB(255, 44, 44, 46),
highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastElevatedColor: Color.fromARGB(255, 54, 54, 56),
);
/// The color for content layered on top of secondary backgrounds, equivalent
/// to [UIColor.tertiarySystemBackground](https://developer.apple.com/documentation/uikit/uicolor/3173154-tertiarysystembackground).
///
/// Typically used for designs that have a white primary background in a light environment.
static const CupertinoDynamicColor tertiarySystemBackground = CupertinoDynamicColor(
debugLabel: 'tertiarySystemBackground',
color: Color.fromARGB(255, 255, 255, 255),
darkColor: Color.fromARGB(255, 44, 44, 46),
highContrastColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastColor: Color.fromARGB(255, 54, 54, 56),
elevatedColor: Color.fromARGB(255, 255, 255, 255),
darkElevatedColor: Color.fromARGB(255, 58, 58, 60),
highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastElevatedColor: Color.fromARGB(255, 68, 68, 70),
);
/// The color for the main background of your grouped interface, equivalent to
/// [UIColor.systemGroupedBackground](https://developer.apple.com/documentation/uikit/uicolor/3173145-systemgroupedbackground).
///
/// Typically used for grouped content, including table views and platter-based designs.
static const CupertinoDynamicColor systemGroupedBackground = CupertinoDynamicColor(
debugLabel: 'systemGroupedBackground',
color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 0, 0, 0),
highContrastColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastColor: Color.fromARGB(255, 0, 0, 0),
elevatedColor: Color.fromARGB(255, 242, 242, 247),
darkElevatedColor: Color.fromARGB(255, 28, 28, 30),
highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastElevatedColor: Color.fromARGB(255, 36, 36, 38),
);
/// The color for content layered on top of the main background of your grouped interface,
/// equivalent to [UIColor.secondarySystemGroupedBackground](https://developer.apple.com/documentation/uikit/uicolor/3173138-secondarysystemgroupedbackground).
///
/// Typically used for grouped content, including table views and platter-based designs.
static const CupertinoDynamicColor secondarySystemGroupedBackground = CupertinoDynamicColor(
debugLabel: 'secondarySystemGroupedBackground',
color: Color.fromARGB(255, 255, 255, 255),
darkColor: Color.fromARGB(255, 28, 28, 30),
highContrastColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastColor: Color.fromARGB(255, 36, 36, 38),
elevatedColor: Color.fromARGB(255, 255, 255, 255),
darkElevatedColor: Color.fromARGB(255, 44, 44, 46),
highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastElevatedColor: Color.fromARGB(255, 54, 54, 56),
);
/// The color for content layered on top of secondary backgrounds of your grouped interface,
/// equivalent to [UIColor.tertiarySystemGroupedBackground](https://developer.apple.com/documentation/uikit/uicolor/3173155-tertiarysystemgroupedbackground).
///
/// Typically used for grouped content, including table views and platter-based designs.
static const CupertinoDynamicColor tertiarySystemGroupedBackground = CupertinoDynamicColor(
debugLabel: 'tertiarySystemGroupedBackground',
color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 44, 44, 46),
highContrastColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastColor: Color.fromARGB(255, 54, 54, 56),
elevatedColor: Color.fromARGB(255, 242, 242, 247),
darkElevatedColor: Color.fromARGB(255, 58, 58, 60),
highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastElevatedColor: Color.fromARGB(255, 68, 68, 70),
);
/// The color for thin borders or divider lines that allows some underlying content to be visible,
/// equivalent to [UIColor.separator](https://developer.apple.com/documentation/uikit/uicolor/3173139-separator).
static const CupertinoDynamicColor separator = CupertinoDynamicColor(
debugLabel: 'separator',
color: Color.fromARGB(73, 60, 60, 67),
darkColor: Color.fromARGB(153, 84, 84, 88),
highContrastColor: Color.fromARGB(94, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(173, 84, 84, 88),
elevatedColor: Color.fromARGB(73, 60, 60, 67),
darkElevatedColor: Color.fromARGB(153, 210, 210, 210),
highContrastElevatedColor: Color.fromARGB(94, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(173, 84, 84, 88),
);
/// The color for borders or divider lines that hide any underlying content,
/// equivalent to [UIColor.opaqueSeparator](https://developer.apple.com/documentation/uikit/uicolor/3173133-opaqueseparator).
static const CupertinoDynamicColor opaqueSeparator = CupertinoDynamicColor(
debugLabel: 'opaqueSeparator',
color: Color.fromARGB(255, 198, 198, 200),
darkColor: Color.fromARGB(255, 56, 56, 58),
highContrastColor: Color.fromARGB(255, 198, 198, 200),
darkHighContrastColor: Color.fromARGB(255, 56, 56, 58),
elevatedColor: Color.fromARGB(255, 198, 198, 200),
darkElevatedColor: Color.fromARGB(255, 56, 56, 58),
highContrastElevatedColor: Color.fromARGB(255, 198, 198, 200),
darkHighContrastElevatedColor: Color.fromARGB(255, 56, 56, 58),
);
/// The color for links, equivalent to
/// [UIColor.link](https://developer.apple.com/documentation/uikit/uicolor/3173132-link).
static const CupertinoDynamicColor link = CupertinoDynamicColor(
debugLabel: 'link',
color: Color.fromARGB(255, 0, 122, 255),
darkColor: Color.fromARGB(255, 9, 132, 255),
highContrastColor: Color.fromARGB(255, 0, 122, 255),
darkHighContrastColor: Color.fromARGB(255, 9, 132, 255),
elevatedColor: Color.fromARGB(255, 0, 122, 255),
darkElevatedColor: Color.fromARGB(255, 9, 132, 255),
highContrastElevatedColor: Color.fromARGB(255, 0, 122, 255),
darkHighContrastElevatedColor: Color.fromARGB(255, 9, 132, 255),
);
}
/// A [Color] subclass that represents a family of colors, and the correct effective
/// color in the color family.
///
/// When used as a regular color, [CupertinoDynamicColor] is equivalent to the
/// effective color (i.e. [CupertinoDynamicColor.value] will come from the effective
/// color), which is determined by the [BuildContext] it is last resolved against.
/// If it has never been resolved, the light, normal contrast, base elevation variant
/// [CupertinoDynamicColor.color] will be the default effective color.
///
/// Sometimes manually resolving a [CupertinoDynamicColor] is not necessary, because
/// the Cupertino Library provides built-in support for it.
///
/// ### Using [CupertinoDynamicColor] in a Cupertino widget
///
/// When a Cupertino widget is provided with a [CupertinoDynamicColor], either
/// directly in its constructor, or from an [InheritedWidget] it depends on (for example,
/// [DefaultTextStyle]), the widget will automatically resolve the color using
/// [CupertinoDynamicColor.resolve] against its own [BuildContext], on a best-effort
/// basis.
///
/// {@tool snippet}
/// By default a [CupertinoButton] has no background color. The following sample
/// code shows how to build a [CupertinoButton] that appears white in light mode,
/// and changes automatically to black in dark mode.
///
/// ```dart
/// CupertinoButton(
/// // CupertinoDynamicColor works out of box in a CupertinoButton.
/// color: const CupertinoDynamicColor.withBrightness(
/// color: CupertinoColors.white,
/// darkColor: CupertinoColors.black,
/// ),
/// onPressed: () { },
/// child: child,
/// )
/// ```
/// {@end-tool}
///
/// ### Using a [CupertinoDynamicColor] from a [CupertinoTheme]
///
/// When referring to a [CupertinoTheme] color, generally the color will already
/// have adapted to the ambient [BuildContext], because [CupertinoTheme.of]
/// implicitly resolves all the colors used in the retrieved [CupertinoThemeData],
/// before returning it.
///
/// {@tool snippet}
/// The following code sample creates a [Container] with the `primaryColor` of the
/// current theme. If `primaryColor` is a [CupertinoDynamicColor], the container
/// will be adaptive, thanks to [CupertinoTheme.of]: it will switch to `primaryColor`'s
/// dark variant once dark mode is turned on, and turns to primaryColor`'s high
/// contrast variant when [MediaQueryData.highContrast] is requested in the ambient
/// [MediaQuery], etc.
///
/// ```dart
/// Container(
/// // Container is not a Cupertino widget, but CupertinoTheme.of implicitly
/// // resolves colors used in the retrieved CupertinoThemeData.
/// color: CupertinoTheme.of(context).primaryColor,
/// )
/// ```
/// {@end-tool}
///
/// ### Manually Resolving a [CupertinoDynamicColor]
///
/// When used to configure a non-Cupertino widget, or wrapped in an object opaque
/// to the receiving Cupertino component, a [CupertinoDynamicColor] may need to be
/// manually resolved using [CupertinoDynamicColor.resolve], before it can used
/// to paint. For example, to use a custom [Border] in a [CupertinoNavigationBar],
/// the colors used in the [Border] have to be resolved manually before being passed
/// to [CupertinoNavigationBar]'s constructor.
///
/// {@tool snippet}
///
/// The following code samples demonstrate two cases where you have to manually
/// resolve a [CupertinoDynamicColor].
///
/// ```dart
/// CupertinoNavigationBar(
/// // CupertinoNavigationBar does not know how to resolve colors used in
/// // a Border class.
/// border: Border(
/// bottom: BorderSide(
/// color: CupertinoDynamicColor.resolve(CupertinoColors.systemBlue, context),
/// ),
/// ),
/// )
/// ```
///
/// ```dart
/// Container(
/// // Container is not a Cupertino widget.
/// color: CupertinoDynamicColor.resolve(CupertinoColors.systemBlue, context),
/// )
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [CupertinoUserInterfaceLevel], an [InheritedWidget] that may affect color
/// resolution of a [CupertinoDynamicColor].
/// * [CupertinoTheme.of], a static method that retrieves the ambient [CupertinoThemeData],
/// and then resolves [CupertinoDynamicColor]s used in the retrieved data.
@immutable
class CupertinoDynamicColor with Diagnosticable implements Color {
/// Creates an adaptive [Color] that changes its effective color based on the
/// [BuildContext] given. The default effective color is [color].
const CupertinoDynamicColor({
String? debugLabel,
required Color color,
required Color darkColor,
required Color highContrastColor,
required Color darkHighContrastColor,
required Color elevatedColor,
required Color darkElevatedColor,
required Color highContrastElevatedColor,
required Color darkHighContrastElevatedColor,
}) : this._(
color,
color,
darkColor,
highContrastColor,
darkHighContrastColor,
elevatedColor,
darkElevatedColor,
highContrastElevatedColor,
darkHighContrastElevatedColor,
null,
debugLabel,
);
/// Creates an adaptive [Color] that changes its effective color based on the
/// given [BuildContext]'s brightness (from [MediaQueryData.platformBrightness]
/// or [CupertinoThemeData.brightness]) and accessibility contrast setting
/// ([MediaQueryData.highContrast]). The default effective color is [color].
const CupertinoDynamicColor.withBrightnessAndContrast({
String? debugLabel,
required Color color,
required Color darkColor,
required Color highContrastColor,
required Color darkHighContrastColor,
}) : this(
debugLabel: debugLabel,
color: color,
darkColor: darkColor,
highContrastColor: highContrastColor,
darkHighContrastColor: darkHighContrastColor,
elevatedColor: color,
darkElevatedColor: darkColor,
highContrastElevatedColor: highContrastColor,
darkHighContrastElevatedColor: darkHighContrastColor,
);
/// Creates an adaptive [Color] that changes its effective color based on the given
/// [BuildContext]'s brightness (from [MediaQueryData.platformBrightness] or
/// [CupertinoThemeData.brightness]). The default effective color is [color].
const CupertinoDynamicColor.withBrightness({
String? debugLabel,
required Color color,
required Color darkColor,
}) : this(
debugLabel: debugLabel,
color: color,
darkColor: darkColor,
highContrastColor: color,
darkHighContrastColor: darkColor,
elevatedColor: color,
darkElevatedColor: darkColor,
highContrastElevatedColor: color,
darkHighContrastElevatedColor: darkColor,
);
const CupertinoDynamicColor._(
this._effectiveColor,
this.color,
this.darkColor,
this.highContrastColor,
this.darkHighContrastColor,
this.elevatedColor,
this.darkElevatedColor,
this.highContrastElevatedColor,
this.darkHighContrastElevatedColor,
this._debugResolveContext,
this._debugLabel,
);
/// The current effective color.
///
/// Defaults to [color] if this [CupertinoDynamicColor] has never been
/// resolved.
final Color _effectiveColor;
final String? _debugLabel;
final Element? _debugResolveContext;
/// The color to use when the [BuildContext] implies a combination of light mode,
/// normal contrast, and base interface elevation.
///
/// In other words, this color will be the effective color of the [CupertinoDynamicColor]
/// after it is resolved against a [BuildContext] that:
/// - has a [CupertinoTheme] whose [CupertinoThemeData.brightness] is [Brightness.light],
/// or a [MediaQuery] whose [MediaQueryData.platformBrightness] is [Brightness.light].
/// - has a [MediaQuery] whose [MediaQueryData.highContrast] is `false`.
/// - has a [CupertinoUserInterfaceLevel] that indicates [CupertinoUserInterfaceLevelData.base].
final Color color;
/// The color to use when the [BuildContext] implies a combination of dark mode,
/// normal contrast, and base interface elevation.
///
/// In other words, this color will be the effective color of the [CupertinoDynamicColor]
/// after it is resolved against a [BuildContext] that:
/// - has a [CupertinoTheme] whose [CupertinoThemeData.brightness] is [Brightness.dark],
/// or a [MediaQuery] whose [MediaQueryData.platformBrightness] is [Brightness.dark].
/// - has a [MediaQuery] whose [MediaQueryData.highContrast] is `false`.
/// - has a [CupertinoUserInterfaceLevel] that indicates [CupertinoUserInterfaceLevelData.base].
final Color darkColor;
/// The color to use when the [BuildContext] implies a combination of light mode,
/// high contrast, and base interface elevation.
///
/// In other words, this color will be the effective color of the [CupertinoDynamicColor]
/// after it is resolved against a [BuildContext] that:
/// - has a [CupertinoTheme] whose [CupertinoThemeData.brightness] is [Brightness.light],
/// or a [MediaQuery] whose [MediaQueryData.platformBrightness] is [Brightness.light].
/// - has a [MediaQuery] whose [MediaQueryData.highContrast] is `true`.
/// - has a [CupertinoUserInterfaceLevel] that indicates [CupertinoUserInterfaceLevelData.base].
final Color highContrastColor;
/// The color to use when the [BuildContext] implies a combination of dark mode,
/// high contrast, and base interface elevation.
///
/// In other words, this color will be the effective color of the [CupertinoDynamicColor]
/// after it is resolved against a [BuildContext] that:
/// - has a [CupertinoTheme] whose [CupertinoThemeData.brightness] is [Brightness.dark],
/// or a [MediaQuery] whose [MediaQueryData.platformBrightness] is [Brightness.dark].
/// - has a [MediaQuery] whose [MediaQueryData.highContrast] is `true`.
/// - has a [CupertinoUserInterfaceLevel] that indicates [CupertinoUserInterfaceLevelData.base].
final Color darkHighContrastColor;
/// The color to use when the [BuildContext] implies a combination of light mode,
/// normal contrast, and elevated interface elevation.
///
/// In other words, this color will be the effective color of the [CupertinoDynamicColor]
/// after it is resolved against a [BuildContext] that:
/// - has a [CupertinoTheme] whose [CupertinoThemeData.brightness] is [Brightness.light],
/// or a [MediaQuery] whose [MediaQueryData.platformBrightness] is [Brightness.light].
/// - has a [MediaQuery] whose [MediaQueryData.highContrast] is `false`.
/// - has a [CupertinoUserInterfaceLevel] that indicates [CupertinoUserInterfaceLevelData.elevated].
final Color elevatedColor;
/// The color to use when the [BuildContext] implies a combination of dark mode,
/// normal contrast, and elevated interface elevation.
///
/// In other words, this color will be the effective color of the [CupertinoDynamicColor]
/// after it is resolved against a [BuildContext] that:
/// - has a [CupertinoTheme] whose [CupertinoThemeData.brightness] is [Brightness.dark],
/// or a [MediaQuery] whose [MediaQueryData.platformBrightness] is [Brightness.dark].
/// - has a [MediaQuery] whose [MediaQueryData.highContrast] is `false`.
/// - has a [CupertinoUserInterfaceLevel] that indicates [CupertinoUserInterfaceLevelData.elevated].
final Color darkElevatedColor;
/// The color to use when the [BuildContext] implies a combination of light mode,
/// high contrast, and elevated interface elevation.
///
/// In other words, this color will be the effective color of the [CupertinoDynamicColor]
/// after it is resolved against a [BuildContext] that:
/// - has a [CupertinoTheme] whose [CupertinoThemeData.brightness] is [Brightness.light],
/// or a [MediaQuery] whose [MediaQueryData.platformBrightness] is [Brightness.light].
/// - has a [MediaQuery] whose [MediaQueryData.highContrast] is `true`.
/// - has a [CupertinoUserInterfaceLevel] that indicates [CupertinoUserInterfaceLevelData.elevated].
final Color highContrastElevatedColor;
/// The color to use when the [BuildContext] implies a combination of dark mode,
/// high contrast, and elevated interface elevation.
///
/// In other words, this color will be the effective color of the [CupertinoDynamicColor]
/// after it is resolved against a [BuildContext] that:
/// - has a [CupertinoTheme] whose [CupertinoThemeData.brightness] is [Brightness.dark],
/// or a [MediaQuery] whose [MediaQueryData.platformBrightness] is [Brightness.dark].
/// - has a [MediaQuery] whose [MediaQueryData.highContrast] is `true`.
/// - has a [CupertinoUserInterfaceLevel] that indicates [CupertinoUserInterfaceLevelData.elevated].
final Color darkHighContrastElevatedColor;
/// Resolves the given [Color] by calling [resolveFrom].
///
/// If the given color is already a concrete [Color], it will be returned as is.
/// If the given color is a [CupertinoDynamicColor], but the given [BuildContext]
/// lacks the dependencies required to the color resolution, the default trait
/// value will be used ([Brightness.light] platform brightness, normal contrast,
/// [CupertinoUserInterfaceLevelData.base] elevation level).
///
/// See also:
///
/// * [maybeResolve], which is similar to this function, but will allow a
/// null `resolvable` color.
static Color resolve(Color resolvable, BuildContext context) {
return (resolvable is CupertinoDynamicColor) ? resolvable.resolveFrom(context) : resolvable;
}
/// Resolves the given [Color] by calling [resolveFrom].
///
/// If the given color is already a concrete [Color], it will be returned as is.
/// If the given color is null, returns null.
/// If the given color is a [CupertinoDynamicColor], but the given [BuildContext]
/// lacks the dependencies required to the color resolution, the default trait
/// value will be used ([Brightness.light] platform brightness, normal contrast,
/// [CupertinoUserInterfaceLevelData.base] elevation level).
///
/// See also:
///
/// * [resolve], which is similar to this function, but returns a
/// non-nullable value, and does not allow a null `resolvable` color.
static Color? maybeResolve(Color? resolvable, BuildContext context) {
return (resolvable is CupertinoDynamicColor) ? resolvable.resolveFrom(context) : resolvable;
}
bool get _isPlatformBrightnessDependent {
return color != darkColor ||
elevatedColor != darkElevatedColor ||
highContrastColor != darkHighContrastColor ||
highContrastElevatedColor != darkHighContrastElevatedColor;
}
bool get _isHighContrastDependent {
return color != highContrastColor ||
darkColor != darkHighContrastColor ||
elevatedColor != highContrastElevatedColor ||
darkElevatedColor != darkHighContrastElevatedColor;
}
bool get _isInterfaceElevationDependent {
return color != elevatedColor ||
darkColor != darkElevatedColor ||
highContrastColor != highContrastElevatedColor ||
darkHighContrastColor != darkHighContrastElevatedColor;
}
/// Resolves this [CupertinoDynamicColor] using the provided [BuildContext].
///
/// Calling this method will create a new [CupertinoDynamicColor] that is
/// almost identical to this [CupertinoDynamicColor], except the effective
/// color is changed to adapt to the given [BuildContext].
///
/// For example, if the given [BuildContext] indicates the widgets in the
/// subtree should be displayed in dark mode (the surrounding
/// [CupertinoTheme]'s [CupertinoThemeData.brightness] or [MediaQuery]'s
/// [MediaQueryData.platformBrightness] is [Brightness.dark]), with a high
/// accessibility contrast (the surrounding [MediaQuery]'s
/// [MediaQueryData.highContrast] is `true`), and an elevated interface
/// elevation (the surrounding [CupertinoUserInterfaceLevel]'s `data` is
/// [CupertinoUserInterfaceLevelData.elevated]), the resolved
/// [CupertinoDynamicColor] will be the same as this [CupertinoDynamicColor],
/// except its effective color will be the `darkHighContrastElevatedColor`
/// variant from the original [CupertinoDynamicColor].
///
/// Calling this function may create dependencies on the closest instance of