waft_material/colors.rs
1//! Flutter counterpart: material_ui's `colors.dart`.
2//!
3//! Dart's `MaterialColor` and `MaterialAccentColor` extend `ColorSwatch<int>`, which extends
4//! `Color`. Here each is a [`ColorExtension`] that derefs to painting's [`ColorSwatch`] and
5//! becomes the [`AnyColor`] it is in Dart through `into_any` (see waft-painting's
6//! `PORTING.md`). The swatches in [`Colors`] are `const` tables, as Dart's are.
7
8use std::any::Any;
9use std::fmt::{self, Debug};
10use std::ops::Deref;
11use std::rc::Rc;
12
13use waft_embedder::Color;
14use waft_painting::{AnyColor, ColorExtension, ColorSwatch};
15
16/// Defines a single color as well a color swatch with ten shades of the color.
17///
18/// The color's shades are referred to by index. The greater the index, the
19/// darker the color. There are 10 valid indices: 50, 100, 200, ..., 900.
20/// The value of this color should the same the value of index 500 and `shade500`.
21///
22/// ## Updating to `ColorScheme`
23///
24/// The `ColorScheme` is preferred for
25/// representing colors in applications that are configured
26/// for Material 3 (see `ThemeData.useMaterial3`).
27/// For more information on colors in Material 3 see
28/// the spec at <https://m3.material.io/styles/color/the-color-system>.
29///
30///{@template material_ui.colors.colorRoles}
31/// In Material 3, colors are represented using color roles and
32/// corresponding tokens. Each property in the `ColorScheme` class
33/// represents one color role as defined in the spec above.
34/// {@endtemplate}
35///
36/// ### Material 3 Colors in Flutter
37///
38///{@template material_ui.colors.settingColors}
39/// Flutter's Material widgets can be assigned colors at the widget level
40/// using widget properties,
41/// or at the app level using theme classes.
42///
43/// For example, you can set the background of the `AppBar` by
44/// setting the `AppBar.backgroundColor` to a specific `Color` value.
45///
46/// To globally set the AppBar background color for your app, you
47/// can set the `ThemeData.appBarTheme` property for your `MaterialApp`
48/// using the `ThemeData` class. You can also override
49/// the default appearance of all the `AppBar`s in a widget subtree by
50/// placing the `AppBarTheme` at the root of the subtree.
51///
52/// Alternatively, you can set the `ThemeData.colorScheme` property
53/// to a custom `ColorScheme`. This creates a unified `ColorScheme` to be
54/// used across the app. The `AppBar.backgroundColor` uses the
55/// `ColorScheme.surface` by default.
56///{@endtemplate}
57///
58/// ### Migrating from `MaterialColor` to `ColorScheme`
59///
60/// In most cases, there are new properties in Flutter widgets that
61/// accept a `ColorScheme` instead of a `MaterialColor`.
62///
63/// For example, you may have previously constructed a `ThemeData`
64/// using a primarySwatch:
65///
66/// ```dart
67/// ThemeData(
68/// primarySwatch: Colors.amber,
69/// )
70/// ```
71///
72/// In Material 3, you can use the `ColorScheme` class to
73/// construct a `ThemeData` with the same color palette
74/// by using the `ColorScheme.fromSeed` constructor:
75///
76/// ```dart
77/// ThemeData(
78/// colorScheme: ColorScheme.fromSeed(seedColor: Colors.amber),
79/// )
80/// ```
81///
82/// The `ColorScheme.fromSeed` constructor
83/// will generate a set of tonal palettes,
84/// which are used to create the color scheme.
85///
86/// Alternatively you can use the `ColorScheme.fromSwatch` constructor:
87///
88/// ```dart
89/// ThemeData(
90/// colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.amber),
91/// )
92/// ```
93///
94/// The `ColorScheme.fromSwatch` constructor will
95/// create the color scheme directly from the specific
96/// color values used in the `MaterialColor`.
97///
98///
99/// See also:
100///
101/// * `Colors`, which defines all of the standard material colors.
102#[derive(Clone, PartialEq)]
103pub struct MaterialColor {
104 swatch: ColorSwatch<i32>,
105}
106
107impl MaterialColor {
108 /// Creates a color swatch with a variety of shades.
109 ///
110 /// The `primary` argument should be the 32 bit ARGB value of one of the
111 /// values in the swatch, as would be passed to the `Color.new` constructor
112 /// for that same color, and as is exposed by `value`. (This is distinct from
113 /// the specific index of the color in the swatch.)
114 pub fn new(primary: Color, swatch: impl IntoIterator<Item = (i32, Color)>) -> MaterialColor {
115 MaterialColor {
116 swatch: ColorSwatch::new(primary, swatch),
117 }
118 }
119
120 /// Dart's `const MaterialColor(primary, {...})`, for a table written in the source.
121 pub const fn from_static(primary: Color, swatch: &'static [(i32, Color)]) -> MaterialColor {
122 MaterialColor {
123 swatch: ColorSwatch::from_static(primary, swatch),
124 }
125 }
126
127 /// The lightest shade.
128 pub fn shade50(&self) -> Color {
129 self.get(&50).expect("a Material swatch has shade 50")
130 }
131
132 /// The second lightest shade.
133 pub fn shade100(&self) -> Color {
134 self.get(&100).expect("a Material swatch has shade 100")
135 }
136
137 /// The third lightest shade.
138 pub fn shade200(&self) -> Color {
139 self.get(&200).expect("a Material swatch has shade 200")
140 }
141
142 /// The fourth lightest shade.
143 pub fn shade300(&self) -> Color {
144 self.get(&300).expect("a Material swatch has shade 300")
145 }
146
147 /// The fifth lightest shade.
148 pub fn shade400(&self) -> Color {
149 self.get(&400).expect("a Material swatch has shade 400")
150 }
151
152 /// The default shade.
153 pub fn shade500(&self) -> Color {
154 self.get(&500).expect("a Material swatch has shade 500")
155 }
156
157 /// The fourth darkest shade.
158 pub fn shade600(&self) -> Color {
159 self.get(&600).expect("a Material swatch has shade 600")
160 }
161
162 /// The third darkest shade.
163 pub fn shade700(&self) -> Color {
164 self.get(&700).expect("a Material swatch has shade 700")
165 }
166
167 /// The second darkest shade.
168 pub fn shade800(&self) -> Color {
169 self.get(&800).expect("a Material swatch has shade 800")
170 }
171
172 /// The darkest shade.
173 pub fn shade900(&self) -> Color {
174 self.get(&900).expect("a Material swatch has shade 900")
175 }
176
177 /// The swatch as the `Color` it is in Dart.
178 pub fn into_any(self) -> AnyColor {
179 AnyColor::with_shared(self.swatch.primary(), Rc::new(self))
180 }
181}
182
183impl Deref for MaterialColor {
184 type Target = ColorSwatch<i32>;
185
186 fn deref(&self) -> &ColorSwatch<i32> {
187 &self.swatch
188 }
189}
190
191impl ColorExtension for MaterialColor {
192 fn as_any(&self) -> &dyn Any {
193 self
194 }
195
196 fn eq_extension(&self, other: &dyn ColorExtension) -> bool {
197 other
198 .as_any()
199 .downcast_ref::<MaterialColor>()
200 .is_some_and(|other| other == self)
201 }
202}
203
204impl From<MaterialColor> for AnyColor {
205 fn from(color: MaterialColor) -> AnyColor {
206 color.into_any()
207 }
208}
209
210impl Debug for MaterialColor {
211 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
212 write!(
213 f,
214 "MaterialColor(primary value: {:?})",
215 self.swatch.primary()
216 )
217 }
218}
219
220/// Defines a single accent color as well a swatch of four shades of the
221/// accent color.
222///
223/// The color's shades are referred to by index, the colors with smaller
224/// indices are lighter, larger indices are darker. There are four valid
225/// indices: 100, 200, 400, and 700. The value of this color should be the
226/// same as the value of index 200 and `shade200`.
227///
228/// See also:
229///
230/// * `Colors`, which defines all of the standard material colors.
231/// * <https://material.io/go/design-theming#color-color-schemes>
232#[derive(Clone, PartialEq)]
233pub struct MaterialAccentColor {
234 swatch: ColorSwatch<i32>,
235}
236
237impl MaterialAccentColor {
238 /// Creates a color swatch with a variety of shades appropriate for accent
239 /// colors.
240 pub fn new(
241 primary: Color,
242 swatch: impl IntoIterator<Item = (i32, Color)>,
243 ) -> MaterialAccentColor {
244 MaterialAccentColor {
245 swatch: ColorSwatch::new(primary, swatch),
246 }
247 }
248
249 /// Dart's `const MaterialAccentColor(primary, {...})`, for a table written in the source.
250 pub const fn from_static(
251 primary: Color,
252 swatch: &'static [(i32, Color)],
253 ) -> MaterialAccentColor {
254 MaterialAccentColor {
255 swatch: ColorSwatch::from_static(primary, swatch),
256 }
257 }
258
259 /// The lightest shade.
260 pub fn shade100(&self) -> Color {
261 self.get(&100).expect("a Material swatch has shade 100")
262 }
263
264 /// The default shade.
265 pub fn shade200(&self) -> Color {
266 self.get(&200).expect("a Material swatch has shade 200")
267 }
268
269 /// The second darkest shade.
270 pub fn shade400(&self) -> Color {
271 self.get(&400).expect("a Material swatch has shade 400")
272 }
273
274 /// The darkest shade.
275 pub fn shade700(&self) -> Color {
276 self.get(&700).expect("a Material swatch has shade 700")
277 }
278
279 /// The swatch as the `Color` it is in Dart.
280 pub fn into_any(self) -> AnyColor {
281 AnyColor::with_shared(self.swatch.primary(), Rc::new(self))
282 }
283}
284
285impl Deref for MaterialAccentColor {
286 type Target = ColorSwatch<i32>;
287
288 fn deref(&self) -> &ColorSwatch<i32> {
289 &self.swatch
290 }
291}
292
293impl ColorExtension for MaterialAccentColor {
294 fn as_any(&self) -> &dyn Any {
295 self
296 }
297
298 fn eq_extension(&self, other: &dyn ColorExtension) -> bool {
299 other
300 .as_any()
301 .downcast_ref::<MaterialAccentColor>()
302 .is_some_and(|other| other == self)
303 }
304}
305
306impl From<MaterialAccentColor> for AnyColor {
307 fn from(color: MaterialAccentColor) -> AnyColor {
308 color.into_any()
309 }
310}
311
312impl Debug for MaterialAccentColor {
313 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
314 write!(
315 f,
316 "MaterialAccentColor(primary value: {:?})",
317 self.swatch.primary()
318 )
319 }
320}
321
322/// `Color` and `ColorSwatch` constants which represent Material design's
323/// [color palette](https://material.io/design/color/).
324///
325/// Instead of using an absolute color from these palettes, consider using
326/// `Theme.of` to obtain the local `ThemeData.colorScheme`, which defines
327/// the colors that most of the Material components use by default.
328///
329///
330/// Most swatches have colors from 100 to 900 in increments of one hundred, plus
331/// the color 50. The smaller the number, the more pale the color. The greater
332/// the number, the darker the color. The accent swatches (e.g. [`RED_ACCENT`](Self::RED_ACCENT)) only
333/// have the values 100, 200, 400, and 700.
334///
335/// In addition, a series of blacks and whites with common opacities are
336/// available. For example, [`BLACK54`](Self::BLACK54) is a pure black with 54% opacity.
337///
338/// <callout-box>
339///
340// TODO(framework): Add unit tests to this code snippet.
341// https://github.com/flutter/flutter/issues/188530
342///
343/// To select a specific color from one of the swatches, index into the swatch
344/// using an integer for the specific color desired, as follows:
345///
346/// ```dart
347/// Color selection = Colors.green[400]!; // Selects a mid-range green.
348/// ```
349///
350/// </callout-box>
351///
352/// <callout-box>
353///
354// TODO(framework): Add unit tests to this code snippet.
355// https://github.com/flutter/flutter/issues/188530
356///
357/// Each `ColorSwatch` constant is a color and can used directly. For example:
358///
359/// ```dart
360/// Container(
361/// color: Colors.blue, // same as Colors.blue[500] or Colors.blue.shade500
362/// )
363/// ```
364///
365/// </callout-box>
366///
367/// ## Color palettes
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/// ## Blacks and whites
424///
425/// These colors are identified by their transparency. The low transparency
426/// levels (e.g. [`Colors::WHITE12`](Colors::WHITE12) and [`Colors::WHITE10`](Colors::WHITE10)) are very hard to see and
427/// should be avoided in general. They are intended for very subtle effects.
428///
429/// 
430/// 
431///
432/// The [`Colors::TRANSPARENT`](Colors::TRANSPARENT) color isn't shown here because it is entirely
433/// invisible!
434///
435/// See also:
436///
437/// * Cookbook: [Use themes to share colors and font styles](https://docs.flutter.dev/cookbook/design/themes)
438pub struct Colors;
439
440impl Colors {
441 /// Completely invisible.
442 pub const TRANSPARENT: Color = Color::new(0x00000000);
443
444 /// Completely opaque black.
445 ///
446 /// 
447 ///
448 /// See also:
449 ///
450 /// * [`BLACK87`](Self::BLACK87), [`BLACK54`](Self::BLACK54), [`BLACK45`](Self::BLACK45), [`BLACK38`](Self::BLACK38), [`BLACK26`](Self::BLACK26), [`BLACK12`](Self::BLACK12), which
451 /// are variants on this color but with different opacities.
452 /// * [`WHITE`](Self::WHITE), a solid white color.
453 /// * [`TRANSPARENT`](Self::TRANSPARENT), a fully-transparent color.
454 pub const BLACK: Color = Color::new(0xFF000000);
455
456 /// Black with 87% opacity.
457 ///
458 /// This is a good contrasting color for text in light themes.
459 ///
460 /// 
461 ///
462 /// See also:
463 ///
464 /// * `Typography.black`, which uses this color for its text styles.
465 /// * `Theme.of`, which allows you to select colors from the current theme
466 /// rather than hard-coding colors in your build methods.
467 /// * [`BLACK`](Self::BLACK), [`BLACK54`](Self::BLACK54), [`BLACK45`](Self::BLACK45), [`BLACK38`](Self::BLACK38), [`BLACK26`](Self::BLACK26), [`BLACK12`](Self::BLACK12), which
468 /// are variants on this color but with different opacities.
469 pub const BLACK87: Color = Color::new(0xDD000000);
470
471 /// Black with 54% opacity.
472 ///
473 /// This is a color commonly used for headings in light themes. It's also used
474 /// as the mask color behind dialogs.
475 ///
476 /// 
477 ///
478 /// See also:
479 ///
480 /// * `Typography.black`, which uses this color for its text styles.
481 /// * `Theme.of`, which allows you to select colors from the current theme
482 /// rather than hard-coding colors in your build methods.
483 /// * [`BLACK`](Self::BLACK), [`BLACK87`](Self::BLACK87), [`BLACK45`](Self::BLACK45), [`BLACK38`](Self::BLACK38), [`BLACK26`](Self::BLACK26), [`BLACK12`](Self::BLACK12), which
484 /// are variants on this color but with different opacities.
485 pub const BLACK54: Color = Color::new(0x8A000000);
486
487 /// Black with 45% opacity.
488 ///
489 /// 
490 ///
491 /// See also:
492 ///
493 /// * [`BLACK`](Self::BLACK), [`BLACK87`](Self::BLACK87), [`BLACK54`](Self::BLACK54), [`BLACK38`](Self::BLACK38), [`BLACK26`](Self::BLACK26), [`BLACK12`](Self::BLACK12), which
494 /// are variants on this color but with different opacities.
495 pub const BLACK45: Color = Color::new(0x73000000);
496
497 /// Black with 38% opacity.
498 ///
499 /// For light themes, i.e. when the Theme's `ThemeData.brightness` is
500 /// `Brightness.light`, this color is used for disabled icons and for
501 /// placeholder text in `DataTable`.
502 ///
503 /// 
504 ///
505 /// See also:
506 ///
507 /// * [`BLACK`](Self::BLACK), [`BLACK87`](Self::BLACK87), [`BLACK54`](Self::BLACK54), [`BLACK45`](Self::BLACK45), [`BLACK26`](Self::BLACK26), [`BLACK12`](Self::BLACK12), which
508 /// are variants on this color but with different opacities.
509 pub const BLACK38: Color = Color::new(0x61000000);
510
511 /// Black with 26% opacity.
512 ///
513 /// Used for disabled radio buttons and the text of disabled flat buttons in light themes.
514 ///
515 /// 
516 ///
517 /// See also:
518 ///
519 /// * `ThemeData.disabledColor`, which uses this color by default in light themes.
520 /// * `Theme.of`, which allows you to select colors from the current theme
521 /// rather than hard-coding colors in your build methods.
522 /// * [`BLACK`](Self::BLACK), [`BLACK87`](Self::BLACK87), [`BLACK54`](Self::BLACK54), [`BLACK45`](Self::BLACK45), [`BLACK38`](Self::BLACK38), [`BLACK12`](Self::BLACK12), which
523 /// are variants on this color but with different opacities.
524 pub const BLACK26: Color = Color::new(0x42000000);
525
526 /// Black with 12% opacity.
527 ///
528 /// 
529 ///
530 /// Used for the background of disabled raised buttons in light themes.
531 ///
532 /// See also:
533 ///
534 /// * [`BLACK`](Self::BLACK), [`BLACK87`](Self::BLACK87), [`BLACK54`](Self::BLACK54), [`BLACK45`](Self::BLACK45), [`BLACK38`](Self::BLACK38), [`BLACK26`](Self::BLACK26), which
535 /// are variants on this color but with different opacities.
536 pub const BLACK12: Color = Color::new(0x1F000000);
537
538 /// Completely opaque white.
539 ///
540 /// This is a good contrasting color for the `ThemeData.primaryColor` in the
541 /// dark theme. See `ThemeData.brightness`.
542 ///
543 /// 
544 ///
545 /// See also:
546 ///
547 /// * `Typography.white`, which uses this color for its text styles.
548 /// * `Theme.of`, which allows you to select colors from the current theme
549 /// rather than hard-coding colors in your build methods.
550 /// * [`WHITE70`](Self::WHITE70), [`WHITE60`](Self::WHITE60), [`WHITE54`](Self::WHITE54), [`WHITE38`](Self::WHITE38), [`WHITE30`](Self::WHITE30), [`WHITE12`](Self::WHITE12),
551 /// [`WHITE10`](Self::WHITE10), which are variants on this color but with different
552 /// opacities.
553 /// * [`BLACK`](Self::BLACK), a solid black color.
554 /// * [`TRANSPARENT`](Self::TRANSPARENT), a fully-transparent color.
555 pub const WHITE: Color = Color::new(0xFFFFFFFF);
556
557 /// White with 70% opacity.
558 ///
559 /// This is a color commonly used for headings in dark themes.
560 ///
561 /// 
562 ///
563 /// See also:
564 ///
565 /// * `Typography.white`, which uses this color for its text styles.
566 /// * `Theme.of`, which allows you to select colors from the current theme
567 /// rather than hard-coding colors in your build methods.
568 /// * [`WHITE`](Self::WHITE), [`WHITE60`](Self::WHITE60), [`WHITE54`](Self::WHITE54), [`WHITE38`](Self::WHITE38), [`WHITE30`](Self::WHITE30), [`WHITE12`](Self::WHITE12),
569 /// [`WHITE10`](Self::WHITE10), which are variants on this color but with different
570 /// opacities.
571 pub const WHITE70: Color = Color::new(0xB3FFFFFF);
572
573 /// White with 60% opacity.
574 ///
575 /// Used for medium-emphasis text and hint text when `ThemeData.brightness` is
576 /// set to `Brightness.dark`.
577 ///
578 /// 
579 ///
580 /// See also:
581 ///
582 /// * `ExpandIcon`, which uses this color for dark themes.
583 /// * `Theme.of`, which allows you to select colors from the current theme
584 /// rather than hard-coding colors in your build methods.
585 /// * [`WHITE`](Self::WHITE), [`WHITE54`](Self::WHITE54), [`WHITE30`](Self::WHITE30), [`WHITE38`](Self::WHITE38), [`WHITE12`](Self::WHITE12), [`WHITE10`](Self::WHITE10), which
586 /// are variants on this color but with different opacities.
587 pub const WHITE60: Color = Color::new(0x99FFFFFF);
588
589 /// White with 54% opacity.
590 ///
591 /// 
592 ///
593 /// See also:
594 ///
595 /// * `Theme.of`, which allows you to select colors from the current theme
596 /// rather than hard-coding colors in your build methods.
597 /// * [`WHITE`](Self::WHITE), [`WHITE60`](Self::WHITE60), [`WHITE38`](Self::WHITE38), [`WHITE30`](Self::WHITE30), [`WHITE12`](Self::WHITE12), [`WHITE10`](Self::WHITE10), which
598 /// are variants on this color but with different opacities.
599 pub const WHITE54: Color = Color::new(0x8AFFFFFF);
600
601 /// White with 38% opacity.
602 ///
603 /// Used for disabled radio buttons and the text of disabled flat buttons in dark themes.
604 ///
605 /// 
606 ///
607 /// See also:
608 ///
609 /// * `ThemeData.disabledColor`, which uses this color by default in dark themes.
610 /// * `Theme.of`, which allows you to select colors from the current theme
611 /// rather than hard-coding colors in your build methods.
612 /// * [`WHITE`](Self::WHITE), [`WHITE60`](Self::WHITE60), [`WHITE54`](Self::WHITE54), [`WHITE70`](Self::WHITE70), [`WHITE30`](Self::WHITE30), [`WHITE12`](Self::WHITE12),
613 /// [`WHITE10`](Self::WHITE10), which are variants on this color but with different
614 /// opacities.
615 pub const WHITE38: Color = Color::new(0x62FFFFFF);
616
617 /// White with 30% opacity.
618 ///
619 /// 
620 ///
621 /// See also:
622 ///
623 /// * `Theme.of`, which allows you to select colors from the current theme
624 /// rather than hard-coding colors in your build methods.
625 /// * [`WHITE`](Self::WHITE), [`WHITE60`](Self::WHITE60), [`WHITE54`](Self::WHITE54), [`WHITE70`](Self::WHITE70), [`WHITE38`](Self::WHITE38), [`WHITE12`](Self::WHITE12),
626 /// [`WHITE10`](Self::WHITE10), which are variants on this color but with different
627 /// opacities.
628 pub const WHITE30: Color = Color::new(0x4DFFFFFF);
629
630 /// White with 24% opacity.
631 ///
632 /// 
633 ///
634 /// Used for the splash color for filled buttons.
635 ///
636 /// See also:
637 ///
638 /// * [`WHITE`](Self::WHITE), [`WHITE60`](Self::WHITE60), [`WHITE54`](Self::WHITE54), [`WHITE70`](Self::WHITE70), [`WHITE38`](Self::WHITE38), [`WHITE30`](Self::WHITE30),
639 /// [`WHITE10`](Self::WHITE10), which are variants on this color
640 /// but with different opacities.
641 pub const WHITE24: Color = Color::new(0x3DFFFFFF);
642
643 /// White with 12% opacity.
644 ///
645 /// 
646 ///
647 /// Used for the background of disabled raised buttons in dark themes.
648 ///
649 /// See also:
650 ///
651 /// * [`WHITE`](Self::WHITE), [`WHITE60`](Self::WHITE60), [`WHITE54`](Self::WHITE54), [`WHITE70`](Self::WHITE70), [`WHITE38`](Self::WHITE38), [`WHITE30`](Self::WHITE30),
652 /// [`WHITE10`](Self::WHITE10), which are variants on this color but with different
653 /// opacities.
654 pub const WHITE12: Color = Color::new(0x1FFFFFFF);
655
656 /// White with 10% opacity.
657 ///
658 /// 
659 ///
660 /// See also:
661 ///
662 /// * [`WHITE`](Self::WHITE), [`WHITE60`](Self::WHITE60), [`WHITE54`](Self::WHITE54), [`WHITE70`](Self::WHITE70), [`WHITE38`](Self::WHITE38), [`WHITE30`](Self::WHITE30),
663 /// [`WHITE12`](Self::WHITE12), which are variants on this color
664 /// but with different opacities.
665 /// * [`TRANSPARENT`](Self::TRANSPARENT), a fully-transparent color, not far from this one.
666 pub const WHITE10: Color = Color::new(0x1AFFFFFF);
667
668 /// The red primary color and swatch.
669 ///
670 /// 
671 /// 
672 ///
673 /// 
674 /// 
675 ///
676 /// 
677 /// 
678 ///
679 /// <callout-box>
680 ///
681 // TODO(framework): Add unit tests to this code snippet.
682 // https://github.com/flutter/flutter/issues/188530
683 ///
684 /// ```dart
685 /// Icon(
686 /// Icons.widgets,
687 /// color: Colors.red[400],
688 /// )
689 /// ```
690 ///
691 /// </callout-box>
692 ///
693 /// See also:
694 ///
695 /// * [`RED_ACCENT`](Self::RED_ACCENT), the corresponding accent colors.
696 /// * [`DEEP_ORANGE`](Self::DEEP_ORANGE) and [`PINK`](Self::PINK), similar colors.
697 /// * `Theme.of`, which allows you to select colors from the current theme
698 /// rather than hard-coding colors in your build methods.
699 pub const RED: MaterialColor = MaterialColor::from_static(
700 Color::new(Self::RED_PRIMARY_VALUE),
701 &[
702 (50, Color::new(0xFFFFEBEE)),
703 (100, Color::new(0xFFFFCDD2)),
704 (200, Color::new(0xFFEF9A9A)),
705 (300, Color::new(0xFFE57373)),
706 (400, Color::new(0xFFEF5350)),
707 (500, Color::new(Self::RED_PRIMARY_VALUE)),
708 (600, Color::new(0xFFE53935)),
709 (700, Color::new(0xFFD32F2F)),
710 (800, Color::new(0xFFC62828)),
711 (900, Color::new(0xFFB71C1C)),
712 ],
713 );
714 const RED_PRIMARY_VALUE: u32 = 0xFFF44336;
715
716 /// The red accent swatch.
717 ///
718 /// 
719 /// 
720 ///
721 /// 
722 /// 
723 ///
724 /// 
725 /// 
726 ///
727 /// <callout-box>
728 ///
729 // TODO(framework): Add unit tests to this code snippet.
730 // https://github.com/flutter/flutter/issues/188530
731 ///
732 /// ```dart
733 /// Icon(
734 /// Icons.widgets,
735 /// color: Colors.redAccent[400],
736 /// )
737 /// ```
738 ///
739 /// </callout-box>
740 ///
741 /// See also:
742 ///
743 /// * [`RED`](Self::RED), the corresponding primary colors.
744 /// * [`DEEP_ORANGE_ACCENT`](Self::DEEP_ORANGE_ACCENT) and [`PINK_ACCENT`](Self::PINK_ACCENT), similar colors.
745 /// * `Theme.of`, which allows you to select colors from the current theme
746 /// rather than hard-coding colors in your build methods.
747 pub const RED_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
748 Color::new(Self::RED_ACCENT_VALUE),
749 &[
750 (100, Color::new(0xFFFF8A80)),
751 (200, Color::new(Self::RED_ACCENT_VALUE)),
752 (400, Color::new(0xFFFF1744)),
753 (700, Color::new(0xFFD50000)),
754 ],
755 );
756 const RED_ACCENT_VALUE: u32 = 0xFFFF5252;
757
758 /// The pink primary color and swatch.
759 ///
760 /// 
761 /// 
762 ///
763 /// 
764 /// 
765 ///
766 /// 
767 /// 
768 ///
769 /// <callout-box>
770 ///
771 // TODO(framework): Add unit tests to this code snippet.
772 // https://github.com/flutter/flutter/issues/188530
773 ///
774 /// ```dart
775 /// Icon(
776 /// Icons.widgets,
777 /// color: Colors.pink[400],
778 /// )
779 /// ```
780 ///
781 /// </callout-box>
782 ///
783 /// See also:
784 ///
785 /// * [`PINK_ACCENT`](Self::PINK_ACCENT), the corresponding accent colors.
786 /// * [`RED`](Self::RED) and [`PURPLE`](Self::PURPLE), similar colors.
787 /// * `Theme.of`, which allows you to select colors from the current theme
788 /// rather than hard-coding colors in your build methods.
789 pub const PINK: MaterialColor = MaterialColor::from_static(
790 Color::new(Self::PINK_PRIMARY_VALUE),
791 &[
792 (50, Color::new(0xFFFCE4EC)),
793 (100, Color::new(0xFFF8BBD0)),
794 (200, Color::new(0xFFF48FB1)),
795 (300, Color::new(0xFFF06292)),
796 (400, Color::new(0xFFEC407A)),
797 (500, Color::new(Self::PINK_PRIMARY_VALUE)),
798 (600, Color::new(0xFFD81B60)),
799 (700, Color::new(0xFFC2185B)),
800 (800, Color::new(0xFFAD1457)),
801 (900, Color::new(0xFF880E4F)),
802 ],
803 );
804 const PINK_PRIMARY_VALUE: u32 = 0xFFE91E63;
805
806 /// The pink accent color swatch.
807 ///
808 /// 
809 /// 
810 ///
811 /// 
812 /// 
813 ///
814 /// 
815 /// 
816 ///
817 /// <callout-box>
818 ///
819 // TODO(framework): Add unit tests to this code snippet.
820 // https://github.com/flutter/flutter/issues/188530
821 ///
822 /// ```dart
823 /// Icon(
824 /// Icons.widgets,
825 /// color: Colors.pinkAccent[400],
826 /// )
827 /// ```
828 ///
829 /// </callout-box>
830 ///
831 /// See also:
832 ///
833 /// * [`PINK`](Self::PINK), the corresponding primary colors.
834 /// * [`RED_ACCENT`](Self::RED_ACCENT) and [`PURPLE_ACCENT`](Self::PURPLE_ACCENT), similar colors.
835 /// * `Theme.of`, which allows you to select colors from the current theme
836 /// rather than hard-coding colors in your build methods.
837 pub const PINK_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
838 Color::new(Self::PINK_ACCENT_PRIMARY_VALUE),
839 &[
840 (100, Color::new(0xFFFF80AB)),
841 (200, Color::new(Self::PINK_ACCENT_PRIMARY_VALUE)),
842 (400, Color::new(0xFFF50057)),
843 (700, Color::new(0xFFC51162)),
844 ],
845 );
846 const PINK_ACCENT_PRIMARY_VALUE: u32 = 0xFFFF4081;
847
848 /// The purple primary color and swatch.
849 ///
850 /// 
851 /// 
852 ///
853 /// 
854 /// 
855 ///
856 /// 
857 /// 
858 ///
859 /// <callout-box>
860 ///
861 // TODO(framework): Add unit tests to this code snippet.
862 // https://github.com/flutter/flutter/issues/188530
863 ///
864 /// ```dart
865 /// Icon(
866 /// Icons.widgets,
867 /// color: Colors.purple[400],
868 /// )
869 /// ```
870 ///
871 /// </callout-box>
872 ///
873 /// See also:
874 ///
875 /// * [`PURPLE_ACCENT`](Self::PURPLE_ACCENT), the corresponding accent colors.
876 /// * [`DEEP_PURPLE`](Self::DEEP_PURPLE) and [`PINK`](Self::PINK), similar colors.
877 /// * `Theme.of`, which allows you to select colors from the current theme
878 /// rather than hard-coding colors in your build methods.
879 pub const PURPLE: MaterialColor = MaterialColor::from_static(
880 Color::new(Self::PURPLE_PRIMARY_VALUE),
881 &[
882 (50, Color::new(0xFFF3E5F5)),
883 (100, Color::new(0xFFE1BEE7)),
884 (200, Color::new(0xFFCE93D8)),
885 (300, Color::new(0xFFBA68C8)),
886 (400, Color::new(0xFFAB47BC)),
887 (500, Color::new(Self::PURPLE_PRIMARY_VALUE)),
888 (600, Color::new(0xFF8E24AA)),
889 (700, Color::new(0xFF7B1FA2)),
890 (800, Color::new(0xFF6A1B9A)),
891 (900, Color::new(0xFF4A148C)),
892 ],
893 );
894 const PURPLE_PRIMARY_VALUE: u32 = 0xFF9C27B0;
895
896 /// The purple accent color and swatch.
897 ///
898 /// 
899 /// 
900 ///
901 /// 
902 /// 
903 ///
904 /// 
905 /// 
906 ///
907 /// <callout-box>
908 ///
909 // TODO(framework): Add unit tests to this code snippet.
910 // https://github.com/flutter/flutter/issues/188530
911 ///
912 /// ```dart
913 /// Icon(
914 /// Icons.widgets,
915 /// color: Colors.purpleAccent[400],
916 /// )
917 /// ```
918 ///
919 /// </callout-box>
920 ///
921 /// See also:
922 ///
923 /// * [`PURPLE`](Self::PURPLE), the corresponding primary colors.
924 /// * [`DEEP_PURPLE_ACCENT`](Self::DEEP_PURPLE_ACCENT) and [`PINK_ACCENT`](Self::PINK_ACCENT), similar colors.
925 /// * `Theme.of`, which allows you to select colors from the current theme
926 /// rather than hard-coding colors in your build methods.
927 pub const PURPLE_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
928 Color::new(Self::PURPLE_ACCENT_PRIMARY_VALUE),
929 &[
930 (100, Color::new(0xFFEA80FC)),
931 (200, Color::new(Self::PURPLE_ACCENT_PRIMARY_VALUE)),
932 (400, Color::new(0xFFD500F9)),
933 (700, Color::new(0xFFAA00FF)),
934 ],
935 );
936 const PURPLE_ACCENT_PRIMARY_VALUE: u32 = 0xFFE040FB;
937
938 /// The deep purple primary color and swatch.
939 ///
940 /// 
941 /// 
942 ///
943 /// 
944 /// 
945 ///
946 /// 
947 /// 
948 ///
949 /// <callout-box>
950 ///
951 // TODO(framework): Add unit tests to this code snippet.
952 // https://github.com/flutter/flutter/issues/188530
953 ///
954 /// ```dart
955 /// Icon(
956 /// Icons.widgets,
957 /// color: Colors.deepPurple[400],
958 /// )
959 /// ```
960 ///
961 /// </callout-box>
962 ///
963 /// See also:
964 ///
965 /// * [`DEEP_PURPLE_ACCENT`](Self::DEEP_PURPLE_ACCENT), the corresponding accent colors.
966 /// * [`PURPLE`](Self::PURPLE) and [`INDIGO`](Self::INDIGO), similar colors.
967 /// * `Theme.of`, which allows you to select colors from the current theme
968 /// rather than hard-coding colors in your build methods.
969 pub const DEEP_PURPLE: MaterialColor = MaterialColor::from_static(
970 Color::new(Self::DEEP_PURPLE_PRIMARY_VALUE),
971 &[
972 (50, Color::new(0xFFEDE7F6)),
973 (100, Color::new(0xFFD1C4E9)),
974 (200, Color::new(0xFFB39DDB)),
975 (300, Color::new(0xFF9575CD)),
976 (400, Color::new(0xFF7E57C2)),
977 (500, Color::new(Self::DEEP_PURPLE_PRIMARY_VALUE)),
978 (600, Color::new(0xFF5E35B1)),
979 (700, Color::new(0xFF512DA8)),
980 (800, Color::new(0xFF4527A0)),
981 (900, Color::new(0xFF311B92)),
982 ],
983 );
984 const DEEP_PURPLE_PRIMARY_VALUE: u32 = 0xFF673AB7;
985
986 /// The deep purple accent color and swatch.
987 ///
988 /// 
989 /// 
990 ///
991 /// 
992 /// 
993 ///
994 /// 
995 /// 
996 ///
997 /// <callout-box>
998 ///
999 // TODO(framework): Add unit tests to this code snippet.
1000 // https://github.com/flutter/flutter/issues/188530
1001 ///
1002 /// ```dart
1003 /// Icon(
1004 /// Icons.widgets,
1005 /// color: Colors.deepPurpleAccent[400],
1006 /// )
1007 /// ```
1008 ///
1009 /// </callout-box>
1010 ///
1011 /// See also:
1012 ///
1013 /// * [`DEEP_PURPLE`](Self::DEEP_PURPLE), the corresponding primary colors.
1014 /// * [`PURPLE_ACCENT`](Self::PURPLE_ACCENT) and [`INDIGO_ACCENT`](Self::INDIGO_ACCENT), similar colors.
1015 /// * `Theme.of`, which allows you to select colors from the current theme
1016 /// rather than hard-coding colors in your build methods.
1017 pub const DEEP_PURPLE_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1018 Color::new(Self::DEEP_PURPLE_ACCENT_PRIMARY_VALUE),
1019 &[
1020 (100, Color::new(0xFFB388FF)),
1021 (200, Color::new(Self::DEEP_PURPLE_ACCENT_PRIMARY_VALUE)),
1022 (400, Color::new(0xFF651FFF)),
1023 (700, Color::new(0xFF6200EA)),
1024 ],
1025 );
1026 const DEEP_PURPLE_ACCENT_PRIMARY_VALUE: u32 = 0xFF7C4DFF;
1027
1028 /// The indigo primary color and swatch.
1029 ///
1030 /// 
1031 /// 
1032 ///
1033 /// 
1034 /// 
1035 ///
1036 /// 
1037 /// 
1038 ///
1039 /// <callout-box>
1040 ///
1041 // TODO(framework): Add unit tests to this code snippet.
1042 // https://github.com/flutter/flutter/issues/188530
1043 ///
1044 /// ```dart
1045 /// Icon(
1046 /// Icons.widgets,
1047 /// color: Colors.indigo[400],
1048 /// )
1049 /// ```
1050 ///
1051 /// </callout-box>
1052 ///
1053 /// See also:
1054 ///
1055 /// * [`INDIGO_ACCENT`](Self::INDIGO_ACCENT), the corresponding accent colors.
1056 /// * [`BLUE`](Self::BLUE) and [`DEEP_PURPLE`](Self::DEEP_PURPLE), similar colors.
1057 /// * `Theme.of`, which allows you to select colors from the current theme
1058 /// rather than hard-coding colors in your build methods.
1059 pub const INDIGO: MaterialColor = MaterialColor::from_static(
1060 Color::new(Self::INDIGO_PRIMARY_VALUE),
1061 &[
1062 (50, Color::new(0xFFE8EAF6)),
1063 (100, Color::new(0xFFC5CAE9)),
1064 (200, Color::new(0xFF9FA8DA)),
1065 (300, Color::new(0xFF7986CB)),
1066 (400, Color::new(0xFF5C6BC0)),
1067 (500, Color::new(Self::INDIGO_PRIMARY_VALUE)),
1068 (600, Color::new(0xFF3949AB)),
1069 (700, Color::new(0xFF303F9F)),
1070 (800, Color::new(0xFF283593)),
1071 (900, Color::new(0xFF1A237E)),
1072 ],
1073 );
1074 const INDIGO_PRIMARY_VALUE: u32 = 0xFF3F51B5;
1075
1076 /// The indigo accent color and swatch.
1077 ///
1078 /// 
1079 /// 
1080 ///
1081 /// 
1082 /// 
1083 ///
1084 /// 
1085 /// 
1086 ///
1087 /// <callout-box>
1088 ///
1089 // TODO(framework): Add unit tests to this code snippet.
1090 // https://github.com/flutter/flutter/issues/188530
1091 ///
1092 /// ```dart
1093 /// Icon(
1094 /// Icons.widgets,
1095 /// color: Colors.indigoAccent[400],
1096 /// )
1097 /// ```
1098 ///
1099 /// </callout-box>
1100 ///
1101 /// See also:
1102 ///
1103 /// * [`INDIGO`](Self::INDIGO), the corresponding primary colors.
1104 /// * [`BLUE_ACCENT`](Self::BLUE_ACCENT) and [`DEEP_PURPLE_ACCENT`](Self::DEEP_PURPLE_ACCENT), similar colors.
1105 /// * `Theme.of`, which allows you to select colors from the current theme
1106 /// rather than hard-coding colors in your build methods.
1107 pub const INDIGO_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1108 Color::new(Self::INDIGO_ACCENT_PRIMARY_VALUE),
1109 &[
1110 (100, Color::new(0xFF8C9EFF)),
1111 (200, Color::new(Self::INDIGO_ACCENT_PRIMARY_VALUE)),
1112 (400, Color::new(0xFF3D5AFE)),
1113 (700, Color::new(0xFF304FFE)),
1114 ],
1115 );
1116 const INDIGO_ACCENT_PRIMARY_VALUE: u32 = 0xFF536DFE;
1117
1118 /// The blue primary color and swatch.
1119 ///
1120 /// 
1121 /// 
1122 ///
1123 /// 
1124 /// 
1125 ///
1126 /// 
1127 /// 
1128 ///
1129 /// 
1130 ///
1131 /// <callout-box>
1132 ///
1133 // TODO(framework): Add unit tests to this code snippet.
1134 // https://github.com/flutter/flutter/issues/188530
1135 ///
1136 /// ```dart
1137 /// Icon(
1138 /// Icons.widgets,
1139 /// color: Colors.blue[400],
1140 /// )
1141 /// ```
1142 ///
1143 /// </callout-box>
1144 ///
1145 /// See also:
1146 ///
1147 /// * [`BLUE_ACCENT`](Self::BLUE_ACCENT), the corresponding accent colors.
1148 /// * [`INDIGO`](Self::INDIGO), [`LIGHT_BLUE`](Self::LIGHT_BLUE), and [`BLUE_GREY`](Self::BLUE_GREY), similar colors.
1149 /// * `Theme.of`, which allows you to select colors from the current theme
1150 /// rather than hard-coding colors in your build methods.
1151 pub const BLUE: MaterialColor = MaterialColor::from_static(
1152 Color::new(Self::BLUE_PRIMARY_VALUE),
1153 &[
1154 (50, Color::new(0xFFE3F2FD)),
1155 (100, Color::new(0xFFBBDEFB)),
1156 (200, Color::new(0xFF90CAF9)),
1157 (300, Color::new(0xFF64B5F6)),
1158 (400, Color::new(0xFF42A5F5)),
1159 (500, Color::new(Self::BLUE_PRIMARY_VALUE)),
1160 (600, Color::new(0xFF1E88E5)),
1161 (700, Color::new(0xFF1976D2)),
1162 (800, Color::new(0xFF1565C0)),
1163 (900, Color::new(0xFF0D47A1)),
1164 ],
1165 );
1166 const BLUE_PRIMARY_VALUE: u32 = 0xFF2196F3;
1167
1168 /// The blue accent color and swatch.
1169 ///
1170 /// 
1171 /// 
1172 ///
1173 /// 
1174 /// 
1175 ///
1176 /// 
1177 /// 
1178 ///
1179 /// <callout-box>
1180 ///
1181 // TODO(framework): Add unit tests to this code snippet.
1182 // https://github.com/flutter/flutter/issues/188530
1183 ///
1184 /// ```dart
1185 /// Icon(
1186 /// Icons.widgets,
1187 /// color: Colors.blueAccent[400],
1188 /// )
1189 /// ```
1190 ///
1191 /// </callout-box>
1192 ///
1193 /// See also:
1194 ///
1195 /// * [`BLUE`](Self::BLUE), the corresponding primary colors.
1196 /// * [`INDIGO_ACCENT`](Self::INDIGO_ACCENT) and [`LIGHT_BLUE_ACCENT`](Self::LIGHT_BLUE_ACCENT), similar colors.
1197 /// * `Theme.of`, which allows you to select colors from the current theme
1198 /// rather than hard-coding colors in your build methods.
1199 pub const BLUE_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1200 Color::new(Self::BLUE_ACCENT_PRIMARY_VALUE),
1201 &[
1202 (100, Color::new(0xFF82B1FF)),
1203 (200, Color::new(Self::BLUE_ACCENT_PRIMARY_VALUE)),
1204 (400, Color::new(0xFF2979FF)),
1205 (700, Color::new(0xFF2962FF)),
1206 ],
1207 );
1208 const BLUE_ACCENT_PRIMARY_VALUE: u32 = 0xFF448AFF;
1209
1210 /// The light blue primary color and swatch.
1211 ///
1212 /// 
1213 /// 
1214 ///
1215 /// 
1216 /// 
1217 ///
1218 /// 
1219 /// 
1220 ///
1221 /// <callout-box>
1222 ///
1223 // TODO(framework): Add unit tests to this code snippet.
1224 // https://github.com/flutter/flutter/issues/188530
1225 ///
1226 /// ```dart
1227 /// Icon(
1228 /// Icons.widgets,
1229 /// color: Colors.lightBlue[400],
1230 /// )
1231 /// ```
1232 ///
1233 /// </callout-box>
1234 ///
1235 /// See also:
1236 ///
1237 /// * [`LIGHT_BLUE_ACCENT`](Self::LIGHT_BLUE_ACCENT), the corresponding accent colors.
1238 /// * [`BLUE`](Self::BLUE) and [`CYAN`](Self::CYAN), similar colors.
1239 /// * `Theme.of`, which allows you to select colors from the current theme
1240 /// rather than hard-coding colors in your build methods.
1241 pub const LIGHT_BLUE: MaterialColor = MaterialColor::from_static(
1242 Color::new(Self::LIGHT_BLUE_PRIMARY_VALUE),
1243 &[
1244 (50, Color::new(0xFFE1F5FE)),
1245 (100, Color::new(0xFFB3E5FC)),
1246 (200, Color::new(0xFF81D4FA)),
1247 (300, Color::new(0xFF4FC3F7)),
1248 (400, Color::new(0xFF29B6F6)),
1249 (500, Color::new(Self::LIGHT_BLUE_PRIMARY_VALUE)),
1250 (600, Color::new(0xFF039BE5)),
1251 (700, Color::new(0xFF0288D1)),
1252 (800, Color::new(0xFF0277BD)),
1253 (900, Color::new(0xFF01579B)),
1254 ],
1255 );
1256 const LIGHT_BLUE_PRIMARY_VALUE: u32 = 0xFF03A9F4;
1257
1258 /// The light blue accent swatch.
1259 ///
1260 /// 
1261 /// 
1262 ///
1263 /// 
1264 /// 
1265 ///
1266 /// 
1267 /// 
1268 ///
1269 /// <callout-box>
1270 ///
1271 // TODO(framework): Add unit tests to this code snippet.
1272 // https://github.com/flutter/flutter/issues/188530
1273 ///
1274 /// ```dart
1275 /// Icon(
1276 /// Icons.widgets,
1277 /// color: Colors.lightBlueAccent[400],
1278 /// )
1279 /// ```
1280 ///
1281 /// </callout-box>
1282 ///
1283 /// See also:
1284 ///
1285 /// * [`LIGHT_BLUE`](Self::LIGHT_BLUE), the corresponding primary colors.
1286 /// * [`BLUE_ACCENT`](Self::BLUE_ACCENT) and [`CYAN_ACCENT`](Self::CYAN_ACCENT), similar colors.
1287 /// * `Theme.of`, which allows you to select colors from the current theme
1288 /// rather than hard-coding colors in your build methods.
1289 pub const LIGHT_BLUE_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1290 Color::new(Self::LIGHT_BLUE_ACCENT_PRIMARY_VALUE),
1291 &[
1292 (100, Color::new(0xFF80D8FF)),
1293 (200, Color::new(Self::LIGHT_BLUE_ACCENT_PRIMARY_VALUE)),
1294 (400, Color::new(0xFF00B0FF)),
1295 (700, Color::new(0xFF0091EA)),
1296 ],
1297 );
1298 const LIGHT_BLUE_ACCENT_PRIMARY_VALUE: u32 = 0xFF40C4FF;
1299
1300 /// The cyan primary color and swatch.
1301 ///
1302 /// 
1303 /// 
1304 ///
1305 /// 
1306 /// 
1307 ///
1308 /// 
1309 /// 
1310 ///
1311 /// 
1312 ///
1313 /// <callout-box>
1314 ///
1315 // TODO(framework): Add unit tests to this code snippet.
1316 // https://github.com/flutter/flutter/issues/188530
1317 ///
1318 /// ```dart
1319 /// Icon(
1320 /// Icons.widgets,
1321 /// color: Colors.cyan[400],
1322 /// )
1323 /// ```
1324 ///
1325 /// </callout-box>
1326 ///
1327 /// See also:
1328 ///
1329 /// * [`CYAN_ACCENT`](Self::CYAN_ACCENT), the corresponding accent colors.
1330 /// * [`LIGHT_BLUE`](Self::LIGHT_BLUE), [`TEAL`](Self::TEAL), and [`BLUE_GREY`](Self::BLUE_GREY), similar colors.
1331 /// * `Theme.of`, which allows you to select colors from the current theme
1332 /// rather than hard-coding colors in your build methods.
1333 pub const CYAN: MaterialColor = MaterialColor::from_static(
1334 Color::new(Self::CYAN_PRIMARY_VALUE),
1335 &[
1336 (50, Color::new(0xFFE0F7FA)),
1337 (100, Color::new(0xFFB2EBF2)),
1338 (200, Color::new(0xFF80DEEA)),
1339 (300, Color::new(0xFF4DD0E1)),
1340 (400, Color::new(0xFF26C6DA)),
1341 (500, Color::new(Self::CYAN_PRIMARY_VALUE)),
1342 (600, Color::new(0xFF00ACC1)),
1343 (700, Color::new(0xFF0097A7)),
1344 (800, Color::new(0xFF00838F)),
1345 (900, Color::new(0xFF006064)),
1346 ],
1347 );
1348 const CYAN_PRIMARY_VALUE: u32 = 0xFF00BCD4;
1349
1350 /// The cyan accent color and swatch.
1351 ///
1352 /// 
1353 /// 
1354 ///
1355 /// 
1356 /// 
1357 ///
1358 /// 
1359 /// 
1360 ///
1361 /// <callout-box>
1362 ///
1363 // TODO(framework): Add unit tests to this code snippet.
1364 // https://github.com/flutter/flutter/issues/188530
1365 ///
1366 /// ```dart
1367 /// Icon(
1368 /// Icons.widgets,
1369 /// color: Colors.cyanAccent[400],
1370 /// )
1371 /// ```
1372 ///
1373 /// </callout-box>
1374 ///
1375 /// See also:
1376 ///
1377 /// * [`CYAN`](Self::CYAN), the corresponding primary colors.
1378 /// * [`LIGHT_BLUE_ACCENT`](Self::LIGHT_BLUE_ACCENT) and [`TEAL_ACCENT`](Self::TEAL_ACCENT), similar colors.
1379 /// * `Theme.of`, which allows you to select colors from the current theme
1380 /// rather than hard-coding colors in your build methods.
1381 pub const CYAN_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1382 Color::new(Self::CYAN_ACCENT_PRIMARY_VALUE),
1383 &[
1384 (100, Color::new(0xFF84FFFF)),
1385 (200, Color::new(Self::CYAN_ACCENT_PRIMARY_VALUE)),
1386 (400, Color::new(0xFF00E5FF)),
1387 (700, Color::new(0xFF00B8D4)),
1388 ],
1389 );
1390 const CYAN_ACCENT_PRIMARY_VALUE: u32 = 0xFF18FFFF;
1391
1392 /// The teal primary color and swatch.
1393 ///
1394 /// 
1395 /// 
1396 ///
1397 /// 
1398 /// 
1399 ///
1400 /// 
1401 /// 
1402 ///
1403 /// <callout-box>
1404 ///
1405 // TODO(framework): Add unit tests to this code snippet.
1406 // https://github.com/flutter/flutter/issues/188530
1407 ///
1408 /// ```dart
1409 /// Icon(
1410 /// Icons.widgets,
1411 /// color: Colors.teal[400],
1412 /// )
1413 /// ```
1414 ///
1415 /// </callout-box>
1416 ///
1417 /// See also:
1418 ///
1419 /// * [`TEAL_ACCENT`](Self::TEAL_ACCENT), the corresponding accent colors.
1420 /// * [`GREEN`](Self::GREEN) and [`CYAN`](Self::CYAN), similar colors.
1421 /// * `Theme.of`, which allows you to select colors from the current theme
1422 /// rather than hard-coding colors in your build methods.
1423 pub const TEAL: MaterialColor = MaterialColor::from_static(
1424 Color::new(Self::TEAL_PRIMARY_VALUE),
1425 &[
1426 (50, Color::new(0xFFE0F2F1)),
1427 (100, Color::new(0xFFB2DFDB)),
1428 (200, Color::new(0xFF80CBC4)),
1429 (300, Color::new(0xFF4DB6AC)),
1430 (400, Color::new(0xFF26A69A)),
1431 (500, Color::new(Self::TEAL_PRIMARY_VALUE)),
1432 (600, Color::new(0xFF00897B)),
1433 (700, Color::new(0xFF00796B)),
1434 (800, Color::new(0xFF00695C)),
1435 (900, Color::new(0xFF004D40)),
1436 ],
1437 );
1438 const TEAL_PRIMARY_VALUE: u32 = 0xFF009688;
1439
1440 /// The teal accent color and swatch.
1441 ///
1442 /// 
1443 /// 
1444 ///
1445 /// 
1446 /// 
1447 ///
1448 /// 
1449 /// 
1450 ///
1451 /// <callout-box>
1452 ///
1453 // TODO(framework): Add unit tests to this code snippet.
1454 // https://github.com/flutter/flutter/issues/188530
1455 ///
1456 /// ```dart
1457 /// Icon(
1458 /// Icons.widgets,
1459 /// color: Colors.tealAccent[400],
1460 /// )
1461 /// ```
1462 ///
1463 /// </callout-box>
1464 ///
1465 /// See also:
1466 ///
1467 /// * [`TEAL`](Self::TEAL), the corresponding primary colors.
1468 /// * [`GREEN_ACCENT`](Self::GREEN_ACCENT) and [`CYAN_ACCENT`](Self::CYAN_ACCENT), similar colors.
1469 /// * `Theme.of`, which allows you to select colors from the current theme
1470 /// rather than hard-coding colors in your build methods.
1471 pub const TEAL_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1472 Color::new(Self::TEAL_ACCENT_PRIMARY_VALUE),
1473 &[
1474 (100, Color::new(0xFFA7FFEB)),
1475 (200, Color::new(Self::TEAL_ACCENT_PRIMARY_VALUE)),
1476 (400, Color::new(0xFF1DE9B6)),
1477 (700, Color::new(0xFF00BFA5)),
1478 ],
1479 );
1480 const TEAL_ACCENT_PRIMARY_VALUE: u32 = 0xFF64FFDA;
1481
1482 /// The green primary color and swatch.
1483 ///
1484 /// 
1485 /// 
1486 ///
1487 /// 
1488 /// 
1489 ///
1490 /// 
1491 /// 
1492 ///
1493 /// 
1494 /// 
1495 ///
1496 /// <callout-box>
1497 ///
1498 // TODO(framework): Add unit tests to this code snippet.
1499 // https://github.com/flutter/flutter/issues/188530
1500 ///
1501 /// ```dart
1502 /// Icon(
1503 /// Icons.widgets,
1504 /// color: Colors.green[400],
1505 /// )
1506 /// ```
1507 ///
1508 /// </callout-box>
1509 ///
1510 /// See also:
1511 ///
1512 /// * [`GREEN_ACCENT`](Self::GREEN_ACCENT), the corresponding accent colors.
1513 /// * [`TEAL`](Self::TEAL), [`LIGHT_GREEN`](Self::LIGHT_GREEN), and [`LIME`](Self::LIME), similar colors.
1514 /// * `Theme.of`, which allows you to select colors from the current theme
1515 /// rather than hard-coding colors in your build methods.
1516 pub const GREEN: MaterialColor = MaterialColor::from_static(
1517 Color::new(Self::GREEN_PRIMARY_VALUE),
1518 &[
1519 (50, Color::new(0xFFE8F5E9)),
1520 (100, Color::new(0xFFC8E6C9)),
1521 (200, Color::new(0xFFA5D6A7)),
1522 (300, Color::new(0xFF81C784)),
1523 (400, Color::new(0xFF66BB6A)),
1524 (500, Color::new(Self::GREEN_PRIMARY_VALUE)),
1525 (600, Color::new(0xFF43A047)),
1526 (700, Color::new(0xFF388E3C)),
1527 (800, Color::new(0xFF2E7D32)),
1528 (900, Color::new(0xFF1B5E20)),
1529 ],
1530 );
1531 const GREEN_PRIMARY_VALUE: u32 = 0xFF4CAF50;
1532
1533 /// The green accent color and swatch.
1534 ///
1535 /// 
1536 /// 
1537 ///
1538 /// 
1539 /// 
1540 ///
1541 /// 
1542 /// 
1543 ///
1544 /// 
1545 /// 
1546 ///
1547 /// <callout-box>
1548 ///
1549 // TODO(framework): Add unit tests to this code snippet.
1550 // https://github.com/flutter/flutter/issues/188530
1551 ///
1552 /// ```dart
1553 /// Icon(
1554 /// Icons.widgets,
1555 /// color: Colors.greenAccent[400],
1556 /// )
1557 /// ```
1558 ///
1559 /// </callout-box>
1560 ///
1561 /// See also:
1562 ///
1563 /// * [`GREEN`](Self::GREEN), the corresponding primary colors.
1564 /// * [`TEAL_ACCENT`](Self::TEAL_ACCENT), [`LIGHT_GREEN_ACCENT`](Self::LIGHT_GREEN_ACCENT), and [`LIME_ACCENT`](Self::LIME_ACCENT), similar colors.
1565 /// * `Theme.of`, which allows you to select colors from the current theme
1566 /// rather than hard-coding colors in your build methods.
1567 pub const GREEN_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1568 Color::new(Self::GREEN_ACCENT_PRIMARY_VALUE),
1569 &[
1570 (100, Color::new(0xFFB9F6CA)),
1571 (200, Color::new(Self::GREEN_ACCENT_PRIMARY_VALUE)),
1572 (400, Color::new(0xFF00E676)),
1573 (700, Color::new(0xFF00C853)),
1574 ],
1575 );
1576 const GREEN_ACCENT_PRIMARY_VALUE: u32 = 0xFF69F0AE;
1577
1578 /// The light green primary color and swatch.
1579 ///
1580 /// 
1581 /// 
1582 ///
1583 /// 
1584 /// 
1585 ///
1586 /// 
1587 /// 
1588 ///
1589 /// <callout-box>
1590 ///
1591 // TODO(framework): Add unit tests to this code snippet.
1592 // https://github.com/flutter/flutter/issues/188530
1593 ///
1594 /// ```dart
1595 /// Icon(
1596 /// Icons.widgets,
1597 /// color: Colors.lightGreen[400],
1598 /// )
1599 /// ```
1600 ///
1601 /// </callout-box>
1602 ///
1603 /// See also:
1604 ///
1605 /// * [`LIGHT_GREEN_ACCENT`](Self::LIGHT_GREEN_ACCENT), the corresponding accent colors.
1606 /// * [`GREEN`](Self::GREEN) and [`LIME`](Self::LIME), similar colors.
1607 /// * `Theme.of`, which allows you to select colors from the current theme
1608 /// rather than hard-coding colors in your build methods.
1609 pub const LIGHT_GREEN: MaterialColor = MaterialColor::from_static(
1610 Color::new(Self::LIGHT_GREEN_PRIMARY_VALUE),
1611 &[
1612 (50, Color::new(0xFFF1F8E9)),
1613 (100, Color::new(0xFFDCEDC8)),
1614 (200, Color::new(0xFFC5E1A5)),
1615 (300, Color::new(0xFFAED581)),
1616 (400, Color::new(0xFF9CCC65)),
1617 (500, Color::new(Self::LIGHT_GREEN_PRIMARY_VALUE)),
1618 (600, Color::new(0xFF7CB342)),
1619 (700, Color::new(0xFF689F38)),
1620 (800, Color::new(0xFF558B2F)),
1621 (900, Color::new(0xFF33691E)),
1622 ],
1623 );
1624 const LIGHT_GREEN_PRIMARY_VALUE: u32 = 0xFF8BC34A;
1625
1626 /// The light green accent color and swatch.
1627 ///
1628 /// 
1629 /// 
1630 ///
1631 /// 
1632 /// 
1633 ///
1634 /// 
1635 /// 
1636 ///
1637 /// <callout-box>
1638 ///
1639 // TODO(framework): Add unit tests to this code snippet.
1640 // https://github.com/flutter/flutter/issues/188530
1641 ///
1642 /// ```dart
1643 /// Icon(
1644 /// Icons.widgets,
1645 /// color: Colors.lightGreenAccent[400],
1646 /// )
1647 /// ```
1648 ///
1649 /// </callout-box>
1650 ///
1651 /// See also:
1652 ///
1653 /// * [`LIGHT_GREEN`](Self::LIGHT_GREEN), the corresponding primary colors.
1654 /// * [`GREEN_ACCENT`](Self::GREEN_ACCENT) and [`LIME_ACCENT`](Self::LIME_ACCENT), similar colors.
1655 /// * `Theme.of`, which allows you to select colors from the current theme
1656 /// rather than hard-coding colors in your build methods.
1657 pub const LIGHT_GREEN_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1658 Color::new(Self::LIGHT_GREEN_ACCENT_PRIMARY_VALUE),
1659 &[
1660 (100, Color::new(0xFFCCFF90)),
1661 (200, Color::new(Self::LIGHT_GREEN_ACCENT_PRIMARY_VALUE)),
1662 (400, Color::new(0xFF76FF03)),
1663 (700, Color::new(0xFF64DD17)),
1664 ],
1665 );
1666 const LIGHT_GREEN_ACCENT_PRIMARY_VALUE: u32 = 0xFFB2FF59;
1667
1668 /// The lime primary color and swatch.
1669 ///
1670 /// 
1671 /// 
1672 ///
1673 /// 
1674 /// 
1675 ///
1676 /// 
1677 /// 
1678 ///
1679 /// <callout-box>
1680 ///
1681 // TODO(framework): Add unit tests to this code snippet.
1682 // https://github.com/flutter/flutter/issues/188530
1683 ///
1684 /// ```dart
1685 /// Icon(
1686 /// Icons.widgets,
1687 /// color: Colors.lime[400],
1688 /// )
1689 /// ```
1690 ///
1691 /// </callout-box>
1692 ///
1693 /// See also:
1694 ///
1695 /// * [`LIME_ACCENT`](Self::LIME_ACCENT), the corresponding accent colors.
1696 /// * [`LIGHT_GREEN`](Self::LIGHT_GREEN) and [`YELLOW`](Self::YELLOW), similar colors.
1697 /// * `Theme.of`, which allows you to select colors from the current theme
1698 /// rather than hard-coding colors in your build methods.
1699 pub const LIME: MaterialColor = MaterialColor::from_static(
1700 Color::new(Self::LIME_PRIMARY_VALUE),
1701 &[
1702 (50, Color::new(0xFFF9FBE7)),
1703 (100, Color::new(0xFFF0F4C3)),
1704 (200, Color::new(0xFFE6EE9C)),
1705 (300, Color::new(0xFFDCE775)),
1706 (400, Color::new(0xFFD4E157)),
1707 (500, Color::new(Self::LIME_PRIMARY_VALUE)),
1708 (600, Color::new(0xFFC0CA33)),
1709 (700, Color::new(0xFFAFB42B)),
1710 (800, Color::new(0xFF9E9D24)),
1711 (900, Color::new(0xFF827717)),
1712 ],
1713 );
1714 const LIME_PRIMARY_VALUE: u32 = 0xFFCDDC39;
1715
1716 /// The lime accent primary color and swatch.
1717 ///
1718 /// 
1719 /// 
1720 ///
1721 /// 
1722 /// 
1723 ///
1724 /// 
1725 /// 
1726 ///
1727 /// <callout-box>
1728 ///
1729 // TODO(framework): Add unit tests to this code snippet.
1730 // https://github.com/flutter/flutter/issues/188530
1731 ///
1732 /// ```dart
1733 /// Icon(
1734 /// Icons.widgets,
1735 /// color: Colors.limeAccent[400],
1736 /// )
1737 /// ```
1738 ///
1739 /// </callout-box>
1740 ///
1741 /// See also:
1742 ///
1743 /// * [`LIME`](Self::LIME), the corresponding primary colors.
1744 /// * [`LIGHT_GREEN_ACCENT`](Self::LIGHT_GREEN_ACCENT) and [`YELLOW_ACCENT`](Self::YELLOW_ACCENT), similar colors.
1745 /// * `Theme.of`, which allows you to select colors from the current theme
1746 /// rather than hard-coding colors in your build methods.
1747 pub const LIME_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1748 Color::new(Self::LIME_ACCENT_PRIMARY_VALUE),
1749 &[
1750 (100, Color::new(0xFFF4FF81)),
1751 (200, Color::new(Self::LIME_ACCENT_PRIMARY_VALUE)),
1752 (400, Color::new(0xFFC6FF00)),
1753 (700, Color::new(0xFFAEEA00)),
1754 ],
1755 );
1756 const LIME_ACCENT_PRIMARY_VALUE: u32 = 0xFFEEFF41;
1757
1758 /// The yellow primary color and swatch.
1759 ///
1760 /// 
1761 /// 
1762 ///
1763 /// 
1764 /// 
1765 ///
1766 /// 
1767 /// 
1768 ///
1769 /// <callout-box>
1770 ///
1771 // TODO(framework): Add unit tests to this code snippet.
1772 // https://github.com/flutter/flutter/issues/188530
1773 ///
1774 /// ```dart
1775 /// Icon(
1776 /// Icons.widgets,
1777 /// color: Colors.yellow[400],
1778 /// )
1779 /// ```
1780 ///
1781 /// </callout-box>
1782 ///
1783 /// See also:
1784 ///
1785 /// * [`YELLOW_ACCENT`](Self::YELLOW_ACCENT), the corresponding accent colors.
1786 /// * [`LIME`](Self::LIME) and [`AMBER`](Self::AMBER), similar colors.
1787 /// * `Theme.of`, which allows you to select colors from the current theme
1788 /// rather than hard-coding colors in your build methods.
1789 pub const YELLOW: MaterialColor = MaterialColor::from_static(
1790 Color::new(Self::YELLOW_PRIMARY_VALUE),
1791 &[
1792 (50, Color::new(0xFFFFFDE7)),
1793 (100, Color::new(0xFFFFF9C4)),
1794 (200, Color::new(0xFFFFF59D)),
1795 (300, Color::new(0xFFFFF176)),
1796 (400, Color::new(0xFFFFEE58)),
1797 (500, Color::new(Self::YELLOW_PRIMARY_VALUE)),
1798 (600, Color::new(0xFFFDD835)),
1799 (700, Color::new(0xFFFBC02D)),
1800 (800, Color::new(0xFFF9A825)),
1801 (900, Color::new(0xFFF57F17)),
1802 ],
1803 );
1804 const YELLOW_PRIMARY_VALUE: u32 = 0xFFFFEB3B;
1805
1806 /// The yellow accent color and swatch.
1807 ///
1808 /// 
1809 /// 
1810 ///
1811 /// 
1812 /// 
1813 ///
1814 /// 
1815 /// 
1816 ///
1817 /// <callout-box>
1818 ///
1819 // TODO(framework): Add unit tests to this code snippet.
1820 // https://github.com/flutter/flutter/issues/188530
1821 ///
1822 /// ```dart
1823 /// Icon(
1824 /// Icons.widgets,
1825 /// color: Colors.yellowAccent[400],
1826 /// )
1827 /// ```
1828 ///
1829 /// </callout-box>
1830 ///
1831 /// See also:
1832 ///
1833 /// * [`YELLOW`](Self::YELLOW), the corresponding primary colors.
1834 /// * [`LIME_ACCENT`](Self::LIME_ACCENT) and [`AMBER_ACCENT`](Self::AMBER_ACCENT), similar colors.
1835 /// * `Theme.of`, which allows you to select colors from the current theme
1836 /// rather than hard-coding colors in your build methods.
1837 pub const YELLOW_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1838 Color::new(Self::YELLOW_ACCENT_PRIMARY_VALUE),
1839 &[
1840 (100, Color::new(0xFFFFFF8D)),
1841 (200, Color::new(Self::YELLOW_ACCENT_PRIMARY_VALUE)),
1842 (400, Color::new(0xFFFFEA00)),
1843 (700, Color::new(0xFFFFD600)),
1844 ],
1845 );
1846 const YELLOW_ACCENT_PRIMARY_VALUE: u32 = 0xFFFFFF00;
1847
1848 /// The amber primary color and swatch.
1849 ///
1850 /// 
1851 /// 
1852 ///
1853 /// 
1854 /// 
1855 ///
1856 /// 
1857 /// 
1858 ///
1859 /// <callout-box>
1860 ///
1861 // TODO(framework): Add unit tests to this code snippet.
1862 // https://github.com/flutter/flutter/issues/188530
1863 ///
1864 /// ```dart
1865 /// Icon(
1866 /// Icons.widgets,
1867 /// color: Colors.amber[400],
1868 /// )
1869 /// ```
1870 ///
1871 /// </callout-box>
1872 ///
1873 /// See also:
1874 ///
1875 /// * [`AMBER_ACCENT`](Self::AMBER_ACCENT), the corresponding accent colors.
1876 /// * [`YELLOW`](Self::YELLOW) and [`ORANGE`](Self::ORANGE), similar colors.
1877 /// * `Theme.of`, which allows you to select colors from the current theme
1878 /// rather than hard-coding colors in your build methods.
1879 pub const AMBER: MaterialColor = MaterialColor::from_static(
1880 Color::new(Self::AMBER_PRIMARY_VALUE),
1881 &[
1882 (50, Color::new(0xFFFFF8E1)),
1883 (100, Color::new(0xFFFFECB3)),
1884 (200, Color::new(0xFFFFE082)),
1885 (300, Color::new(0xFFFFD54F)),
1886 (400, Color::new(0xFFFFCA28)),
1887 (500, Color::new(Self::AMBER_PRIMARY_VALUE)),
1888 (600, Color::new(0xFFFFB300)),
1889 (700, Color::new(0xFFFFA000)),
1890 (800, Color::new(0xFFFF8F00)),
1891 (900, Color::new(0xFFFF6F00)),
1892 ],
1893 );
1894 const AMBER_PRIMARY_VALUE: u32 = 0xFFFFC107;
1895
1896 /// The amber accent color and swatch.
1897 ///
1898 /// 
1899 /// 
1900 ///
1901 /// 
1902 /// 
1903 ///
1904 /// 
1905 /// 
1906 ///
1907 /// <callout-box>
1908 ///
1909 // TODO(framework): Add unit tests to this code snippet.
1910 // https://github.com/flutter/flutter/issues/188530
1911 ///
1912 /// ```dart
1913 /// Icon(
1914 /// Icons.widgets,
1915 /// color: Colors.amberAccent[400],
1916 /// )
1917 /// ```
1918 ///
1919 /// </callout-box>
1920 ///
1921 /// See also:
1922 ///
1923 /// * [`AMBER`](Self::AMBER), the corresponding primary colors.
1924 /// * [`YELLOW_ACCENT`](Self::YELLOW_ACCENT) and [`ORANGE_ACCENT`](Self::ORANGE_ACCENT), similar colors.
1925 /// * `Theme.of`, which allows you to select colors from the current theme
1926 /// rather than hard-coding colors in your build methods.
1927 pub const AMBER_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
1928 Color::new(Self::AMBER_ACCENT_PRIMARY_VALUE),
1929 &[
1930 (100, Color::new(0xFFFFE57F)),
1931 (200, Color::new(Self::AMBER_ACCENT_PRIMARY_VALUE)),
1932 (400, Color::new(0xFFFFC400)),
1933 (700, Color::new(0xFFFFAB00)),
1934 ],
1935 );
1936 const AMBER_ACCENT_PRIMARY_VALUE: u32 = 0xFFFFD740;
1937
1938 /// The orange primary color and swatch.
1939 ///
1940 /// 
1941 /// 
1942 ///
1943 /// 
1944 /// 
1945 ///
1946 /// 
1947 /// 
1948 ///
1949 /// 
1950 ///
1951 /// <callout-box>
1952 ///
1953 // TODO(framework): Add unit tests to this code snippet.
1954 // https://github.com/flutter/flutter/issues/188530
1955 ///
1956 /// ```dart
1957 /// Icon(
1958 /// Icons.widgets,
1959 /// color: Colors.orange[400],
1960 /// )
1961 /// ```
1962 ///
1963 /// </callout-box>
1964 ///
1965 /// See also:
1966 ///
1967 /// * [`ORANGE_ACCENT`](Self::ORANGE_ACCENT), the corresponding accent colors.
1968 /// * [`AMBER`](Self::AMBER), [`DEEP_ORANGE`](Self::DEEP_ORANGE), and [`BROWN`](Self::BROWN), similar colors.
1969 /// * `Theme.of`, which allows you to select colors from the current theme
1970 /// rather than hard-coding colors in your build methods.
1971 pub const ORANGE: MaterialColor = MaterialColor::from_static(
1972 Color::new(Self::ORANGE_PRIMARY_VALUE),
1973 &[
1974 (50, Color::new(0xFFFFF3E0)),
1975 (100, Color::new(0xFFFFE0B2)),
1976 (200, Color::new(0xFFFFCC80)),
1977 (300, Color::new(0xFFFFB74D)),
1978 (400, Color::new(0xFFFFA726)),
1979 (500, Color::new(Self::ORANGE_PRIMARY_VALUE)),
1980 (600, Color::new(0xFFFB8C00)),
1981 (700, Color::new(0xFFF57C00)),
1982 (800, Color::new(0xFFEF6C00)),
1983 (900, Color::new(0xFFE65100)),
1984 ],
1985 );
1986 const ORANGE_PRIMARY_VALUE: u32 = 0xFFFF9800;
1987
1988 /// The orange accent color and swatch.
1989 ///
1990 /// 
1991 /// 
1992 ///
1993 /// 
1994 /// 
1995 ///
1996 /// 
1997 /// 
1998 ///
1999 /// <callout-box>
2000 ///
2001 // TODO(framework): Add unit tests to this code snippet.
2002 // https://github.com/flutter/flutter/issues/188530
2003 ///
2004 /// ```dart
2005 /// Icon(
2006 /// Icons.widgets,
2007 /// color: Colors.orangeAccent[400],
2008 /// )
2009 /// ```
2010 ///
2011 /// </callout-box>
2012 ///
2013 /// See also:
2014 ///
2015 /// * [`ORANGE`](Self::ORANGE), the corresponding primary colors.
2016 /// * [`AMBER_ACCENT`](Self::AMBER_ACCENT) and [`DEEP_ORANGE_ACCENT`](Self::DEEP_ORANGE_ACCENT), similar colors.
2017 /// * `Theme.of`, which allows you to select colors from the current theme
2018 /// rather than hard-coding colors in your build methods.
2019 pub const ORANGE_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
2020 Color::new(Self::ORANGE_ACCENT_PRIMARY_VALUE),
2021 &[
2022 (100, Color::new(0xFFFFD180)),
2023 (200, Color::new(Self::ORANGE_ACCENT_PRIMARY_VALUE)),
2024 (400, Color::new(0xFFFF9100)),
2025 (700, Color::new(0xFFFF6D00)),
2026 ],
2027 );
2028 const ORANGE_ACCENT_PRIMARY_VALUE: u32 = 0xFFFFAB40;
2029
2030 /// The deep orange primary color and swatch.
2031 ///
2032 /// 
2033 /// 
2034 ///
2035 /// 
2036 /// 
2037 ///
2038 /// 
2039 /// 
2040 ///
2041 /// 
2042 ///
2043 /// <callout-box>
2044 ///
2045 // TODO(framework): Add unit tests to this code snippet.
2046 // https://github.com/flutter/flutter/issues/188530
2047 ///
2048 /// ```dart
2049 /// Icon(
2050 /// Icons.widgets,
2051 /// color: Colors.deepOrange[400],
2052 /// )
2053 /// ```
2054 ///
2055 /// </callout-box>
2056 ///
2057 /// See also:
2058 ///
2059 /// * [`DEEP_ORANGE_ACCENT`](Self::DEEP_ORANGE_ACCENT), the corresponding accent colors.
2060 /// * [`ORANGE`](Self::ORANGE), [`RED`](Self::RED), and [`BROWN`](Self::BROWN), similar colors.
2061 /// * `Theme.of`, which allows you to select colors from the current theme
2062 /// rather than hard-coding colors in your build methods.
2063 pub const DEEP_ORANGE: MaterialColor = MaterialColor::from_static(
2064 Color::new(Self::DEEP_ORANGE_PRIMARY_VALUE),
2065 &[
2066 (50, Color::new(0xFFFBE9E7)),
2067 (100, Color::new(0xFFFFCCBC)),
2068 (200, Color::new(0xFFFFAB91)),
2069 (300, Color::new(0xFFFF8A65)),
2070 (400, Color::new(0xFFFF7043)),
2071 (500, Color::new(Self::DEEP_ORANGE_PRIMARY_VALUE)),
2072 (600, Color::new(0xFFF4511E)),
2073 (700, Color::new(0xFFE64A19)),
2074 (800, Color::new(0xFFD84315)),
2075 (900, Color::new(0xFFBF360C)),
2076 ],
2077 );
2078 const DEEP_ORANGE_PRIMARY_VALUE: u32 = 0xFFFF5722;
2079
2080 /// The deep orange accent color and swatch.
2081 ///
2082 /// 
2083 /// 
2084 ///
2085 /// 
2086 /// 
2087 ///
2088 /// 
2089 /// 
2090 ///
2091 /// <callout-box>
2092 ///
2093 // TODO(framework): Add unit tests to this code snippet.
2094 // https://github.com/flutter/flutter/issues/188530
2095 ///
2096 /// ```dart
2097 /// Icon(
2098 /// Icons.widgets,
2099 /// color: Colors.deepOrangeAccent[400],
2100 /// )
2101 /// ```
2102 ///
2103 /// </callout-box>
2104 ///
2105 /// See also:
2106 ///
2107 /// * [`DEEP_ORANGE`](Self::DEEP_ORANGE), the corresponding primary colors.
2108 /// * [`ORANGE_ACCENT`](Self::ORANGE_ACCENT) [`RED_ACCENT`](Self::RED_ACCENT), similar colors.
2109 /// * `Theme.of`, which allows you to select colors from the current theme
2110 /// rather than hard-coding colors in your build methods.
2111 pub const DEEP_ORANGE_ACCENT: MaterialAccentColor = MaterialAccentColor::from_static(
2112 Color::new(Self::DEEP_ORANGE_ACCENT_PRIMARY_VALUE),
2113 &[
2114 (100, Color::new(0xFFFF9E80)),
2115 (200, Color::new(Self::DEEP_ORANGE_ACCENT_PRIMARY_VALUE)),
2116 (400, Color::new(0xFFFF3D00)),
2117 (700, Color::new(0xFFDD2C00)),
2118 ],
2119 );
2120 const DEEP_ORANGE_ACCENT_PRIMARY_VALUE: u32 = 0xFFFF6E40;
2121
2122 /// The brown primary color and swatch.
2123 ///
2124 /// 
2125 ///
2126 /// 
2127 ///
2128 /// 
2129 ///
2130 /// This swatch has no corresponding accent color and swatch.
2131 ///
2132 /// <callout-box>
2133 ///
2134 // TODO(framework): Add unit tests to this code snippet.
2135 // https://github.com/flutter/flutter/issues/188530
2136 ///
2137 /// ```dart
2138 /// Icon(
2139 /// Icons.widgets,
2140 /// color: Colors.brown[400],
2141 /// )
2142 /// ```
2143 ///
2144 /// </callout-box>
2145 ///
2146 /// See also:
2147 ///
2148 /// * [`ORANGE`](Self::ORANGE) and [`BLUE_GREY`](Self::BLUE_GREY), vaguely similar colors.
2149 /// * `Theme.of`, which allows you to select colors from the current theme
2150 /// rather than hard-coding colors in your build methods.
2151 pub const BROWN: MaterialColor = MaterialColor::from_static(
2152 Color::new(Self::BROWN_PRIMARY_VALUE),
2153 &[
2154 (50, Color::new(0xFFEFEBE9)),
2155 (100, Color::new(0xFFD7CCC8)),
2156 (200, Color::new(0xFFBCAAA4)),
2157 (300, Color::new(0xFFA1887F)),
2158 (400, Color::new(0xFF8D6E63)),
2159 (500, Color::new(Self::BROWN_PRIMARY_VALUE)),
2160 (600, Color::new(0xFF6D4C41)),
2161 (700, Color::new(0xFF5D4037)),
2162 (800, Color::new(0xFF4E342E)),
2163 (900, Color::new(0xFF3E2723)),
2164 ],
2165 );
2166 const BROWN_PRIMARY_VALUE: u32 = 0xFF795548;
2167
2168 /// The grey primary color and swatch.
2169 ///
2170 /// 
2171 ///
2172 /// 
2173 ///
2174 /// 
2175 ///
2176 /// This swatch has no corresponding accent swatch.
2177 ///
2178 /// This swatch, in addition to the values 50 and 100 to 900 in 100
2179 /// increments, also features the special values 350 and 850. The 350 value is
2180 /// used for raised button while pressed in light themes, and 850 is used for
2181 /// the background color of the dark theme. See `ThemeData.brightness`.
2182 ///
2183 /// <callout-box>
2184 ///
2185 // TODO(framework): Add unit tests to this code snippet.
2186 // https://github.com/flutter/flutter/issues/188530
2187 ///
2188 /// ```dart
2189 /// Icon(
2190 /// Icons.widgets,
2191 /// color: Colors.grey[400],
2192 /// )
2193 /// ```
2194 ///
2195 /// </callout-box>
2196 ///
2197 /// See also:
2198 ///
2199 /// * [`BLUE_GREY`](Self::BLUE_GREY) and [`BROWN`](Self::BROWN), somewhat similar colors.
2200 /// * [`BLACK`](Self::BLACK), [`BLACK87`](Self::BLACK87), [`BLACK54`](Self::BLACK54), [`BLACK45`](Self::BLACK45), [`BLACK38`](Self::BLACK38), [`BLACK26`](Self::BLACK26), [`BLACK12`](Self::BLACK12), which
2201 /// provide a different approach to showing shades of grey.
2202 /// * `Theme.of`, which allows you to select colors from the current theme
2203 /// rather than hard-coding colors in your build methods.
2204 pub const GREY: MaterialColor = MaterialColor::from_static(
2205 Color::new(Self::GREY_PRIMARY_VALUE),
2206 &[
2207 (50, Color::new(0xFFFAFAFA)),
2208 (100, Color::new(0xFFF5F5F5)),
2209 (200, Color::new(0xFFEEEEEE)),
2210 (300, Color::new(0xFFE0E0E0)),
2211 (350, Color::new(0xFFD6D6D6)),
2212 (400, Color::new(0xFFBDBDBD)),
2213 (500, Color::new(Self::GREY_PRIMARY_VALUE)),
2214 (600, Color::new(0xFF757575)),
2215 (700, Color::new(0xFF616161)),
2216 (800, Color::new(0xFF424242)),
2217 (850, Color::new(0xFF303030)),
2218 (900, Color::new(0xFF212121)),
2219 ],
2220 );
2221 const GREY_PRIMARY_VALUE: u32 = 0xFF9E9E9E;
2222
2223 /// The blue-grey primary color and swatch.
2224 ///
2225 /// 
2226 ///
2227 /// 
2228 ///
2229 /// 
2230 ///
2231 /// 
2232 ///
2233 /// This swatch has no corresponding accent swatch.
2234 ///
2235 /// <callout-box>
2236 ///
2237 // TODO(framework): Add unit tests to this code snippet.
2238 // https://github.com/flutter/flutter/issues/188530
2239 ///
2240 /// ```dart
2241 /// Icon(
2242 /// Icons.widgets,
2243 /// color: Colors.blueGrey[400],
2244 /// )
2245 /// ```
2246 ///
2247 /// </callout-box>
2248 ///
2249 /// See also:
2250 ///
2251 /// * [`GREY`](Self::GREY), [`CYAN`](Self::CYAN), and [`BLUE`](Self::BLUE), similar colors.
2252 /// * `Theme.of`, which allows you to select colors from the current theme
2253 /// rather than hard-coding colors in your build methods.
2254 pub const BLUE_GREY: MaterialColor = MaterialColor::from_static(
2255 Color::new(Self::BLUE_GREY_PRIMARY_VALUE),
2256 &[
2257 (50, Color::new(0xFFECEFF1)),
2258 (100, Color::new(0xFFCFD8DC)),
2259 (200, Color::new(0xFFB0BEC5)),
2260 (300, Color::new(0xFF90A4AE)),
2261 (400, Color::new(0xFF78909C)),
2262 (500, Color::new(Self::BLUE_GREY_PRIMARY_VALUE)),
2263 (600, Color::new(0xFF546E7A)),
2264 (700, Color::new(0xFF455A64)),
2265 (800, Color::new(0xFF37474F)),
2266 (900, Color::new(0xFF263238)),
2267 ],
2268 );
2269 const BLUE_GREY_PRIMARY_VALUE: u32 = 0xFF607D8B;
2270
2271 /// The Material Design primary color swatches, excluding grey.
2272 pub const PRIMARIES: &'static [MaterialColor] = &[
2273 Self::RED,
2274 Self::PINK,
2275 Self::PURPLE,
2276 Self::DEEP_PURPLE,
2277 Self::INDIGO,
2278 Self::BLUE,
2279 Self::LIGHT_BLUE,
2280 Self::CYAN,
2281 Self::TEAL,
2282 Self::GREEN,
2283 Self::LIGHT_GREEN,
2284 Self::LIME,
2285 Self::YELLOW,
2286 Self::AMBER,
2287 Self::ORANGE,
2288 Self::DEEP_ORANGE,
2289 Self::BROWN,
2290 // The grey swatch is intentionally omitted because when picking a color
2291 // randomly from this list to colorize an application, picking grey suddenly
2292 // makes the app look disabled.
2293 Self::BLUE_GREY,
2294 ];
2295
2296 /// The Material Design accent color swatches.
2297 pub const ACCENTS: &'static [MaterialAccentColor] = &[
2298 Self::RED_ACCENT,
2299 Self::PINK_ACCENT,
2300 Self::PURPLE_ACCENT,
2301 Self::DEEP_PURPLE_ACCENT,
2302 Self::INDIGO_ACCENT,
2303 Self::BLUE_ACCENT,
2304 Self::LIGHT_BLUE_ACCENT,
2305 Self::CYAN_ACCENT,
2306 Self::TEAL_ACCENT,
2307 Self::GREEN_ACCENT,
2308 Self::LIGHT_GREEN_ACCENT,
2309 Self::LIME_ACCENT,
2310 Self::YELLOW_ACCENT,
2311 Self::AMBER_ACCENT,
2312 Self::ORANGE_ACCENT,
2313 Self::DEEP_ORANGE_ACCENT,
2314 ];
2315}
2316
2317#[cfg(test)]
2318mod tests {
2319 use std::collections::HashSet;
2320
2321 use super::*;
2322
2323 const PRIMARY_KEYS: [i32; 10] = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
2324 const ACCENT_KEYS: [i32; 4] = [100, 200, 400, 700];
2325
2326 #[test]
2327 fn material_color_basic_functionality() {
2328 let color = MaterialColor::new(
2329 Color::new(500),
2330 [
2331 (50, Color::new(0x00000050)),
2332 (100, Color::new(0x00000100)),
2333 (200, Color::new(0x00000200)),
2334 (300, Color::new(0x00000300)),
2335 (400, Color::new(0x00000400)),
2336 (500, Color::new(0x00000500)),
2337 (600, Color::new(0x00000600)),
2338 (700, Color::new(0x00000700)),
2339 (800, Color::new(0x00000800)),
2340 (900, Color::new(0x00000900)),
2341 ],
2342 );
2343
2344 assert_eq!(color.primary().to_argb32(), 500);
2345
2346 assert_eq!(color.get(&50).unwrap().to_argb32(), 0x00000050);
2347 assert_eq!(color.get(&100).unwrap().to_argb32(), 0x00000100);
2348 assert_eq!(color.get(&200).unwrap().to_argb32(), 0x00000200);
2349 assert_eq!(color.get(&300).unwrap().to_argb32(), 0x00000300);
2350 assert_eq!(color.get(&400).unwrap().to_argb32(), 0x00000400);
2351 assert_eq!(color.get(&500).unwrap().to_argb32(), 0x00000500);
2352 assert_eq!(color.get(&600).unwrap().to_argb32(), 0x00000600);
2353 assert_eq!(color.get(&700).unwrap().to_argb32(), 0x00000700);
2354 assert_eq!(color.get(&800).unwrap().to_argb32(), 0x00000800);
2355 assert_eq!(color.get(&900).unwrap().to_argb32(), 0x00000900);
2356
2357 assert_eq!(color.shade50().to_argb32(), 0x00000050);
2358 assert_eq!(color.shade100().to_argb32(), 0x00000100);
2359 assert_eq!(color.shade200().to_argb32(), 0x00000200);
2360 assert_eq!(color.shade300().to_argb32(), 0x00000300);
2361 assert_eq!(color.shade400().to_argb32(), 0x00000400);
2362 assert_eq!(color.shade500().to_argb32(), 0x00000500);
2363 assert_eq!(color.shade600().to_argb32(), 0x00000600);
2364 assert_eq!(color.shade700().to_argb32(), 0x00000700);
2365 assert_eq!(color.shade800().to_argb32(), 0x00000800);
2366 assert_eq!(color.shade900().to_argb32(), 0x00000900);
2367 }
2368
2369 fn distinct_shades(swatch: &ColorSwatch<i32>, keys: &[i32]) -> usize {
2370 keys.iter()
2371 .map(|key| swatch.get(key).unwrap().to_argb32())
2372 .collect::<HashSet<u32>>()
2373 .len()
2374 }
2375
2376 #[test]
2377 fn colors_swatches_do_not_contain_duplicates() {
2378 for color in Colors::PRIMARIES {
2379 assert_eq!(distinct_shades(color, &PRIMARY_KEYS), PRIMARY_KEYS.len());
2380 }
2381
2382 assert_eq!(
2383 distinct_shades(&Colors::GREY, &PRIMARY_KEYS),
2384 PRIMARY_KEYS.len()
2385 );
2386
2387 for color in Colors::ACCENTS {
2388 assert_eq!(distinct_shades(color, &ACCENT_KEYS), ACCENT_KEYS.len());
2389 }
2390 }
2391
2392 #[test]
2393 fn all_color_swatch_colors_are_opaque_and_equal_their_primary_color() {
2394 for color in Colors::PRIMARIES {
2395 assert_eq!(color.primary().to_argb32(), color.shade500().to_argb32());
2396 for key in PRIMARY_KEYS {
2397 assert_eq!(color.get(&key).unwrap().to_argb32() >> 24, 0xFF);
2398 }
2399 }
2400
2401 assert_eq!(
2402 Colors::GREY.primary().to_argb32(),
2403 Colors::GREY.shade500().to_argb32()
2404 );
2405 for key in PRIMARY_KEYS {
2406 assert_eq!(Colors::GREY.get(&key).unwrap().to_argb32() >> 24, 0xFF);
2407 }
2408
2409 for color in Colors::ACCENTS {
2410 assert_eq!(color.primary().to_argb32(), color.shade200().to_argb32());
2411 for key in ACCENT_KEYS {
2412 assert_eq!(color.get(&key).unwrap().to_argb32() >> 24, 0xFF);
2413 }
2414 }
2415 }
2416
2417 #[test]
2418 fn material_color_swatch_comparison() {
2419 let sample_map = [(50, Color::new(0xFFE1F5FE)), (100, Color::new(0xFFB3E5FC))];
2420 let another_map = [(50, Color::new(0xFFE1F5FE)), (100, Color::new(0xFFB3E5FC))];
2421 let first = MaterialColor::new(Color::new(0), sample_map);
2422 let second = MaterialColor::new(Color::new(0), sample_map);
2423 let third = MaterialColor::new(Color::new(0), another_map);
2424 assert_eq!(first, second);
2425 assert_eq!(first, third);
2426 }
2427}