Skip to main content

Colors

Struct Colors 

Source
pub struct Colors;
Expand description

Color and ColorSwatch constants which represent Material design’s color palette.

Instead of using an absolute color from these palettes, consider using Theme.of to obtain the local ThemeData.colorScheme, which defines the colors that most of the Material components use by default.

Most swatches have colors from 100 to 900 in increments of one hundred, plus the color 50. The smaller the number, the more pale the color. The greater the number, the darker the color. The accent swatches (e.g. RED_ACCENT) only have the values 100, 200, 400, and 700.

In addition, a series of blacks and whites with common opacities are available. For example, BLACK54 is a pure black with 54% opacity.

To select a specific color from one of the swatches, index into the swatch using an integer for the specific color desired, as follows:

Color selection = Colors.green[400]!; // Selects a mid-range green.

Each ColorSwatch constant is a color and can used directly. For example:

Container(
  color: Colors.blue, // same as Colors.blue[500] or Colors.blue.shade500
)

§Color palettes

§Blacks and whites

These colors are identified by their transparency. The low transparency levels (e.g. Colors::WHITE12 and Colors::WHITE10) are very hard to see and should be avoided in general. They are intended for very subtle effects.

The Colors::TRANSPARENT color isn’t shown here because it is entirely invisible!

See also:

Implementations§

Source§

impl Colors

Source

pub const TRANSPARENT: Color

Completely invisible.

Source

pub const BLACK: Color

Completely opaque black.

See also:

Source

pub const BLACK87: Color

Black with 87% opacity.

This is a good contrasting color for text in light themes.

See also:

  • Typography.black, which uses this color for its text styles.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
  • BLACK, BLACK54, BLACK45, BLACK38, BLACK26, BLACK12, which are variants on this color but with different opacities.
Source

pub const BLACK54: Color

Black with 54% opacity.

This is a color commonly used for headings in light themes. It’s also used as the mask color behind dialogs.

See also:

  • Typography.black, which uses this color for its text styles.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
  • BLACK, BLACK87, BLACK45, BLACK38, BLACK26, BLACK12, which are variants on this color but with different opacities.
Source

pub const BLACK45: Color

Black with 45% opacity.

See also:

Source

pub const BLACK38: Color

Black with 38% opacity.

For light themes, i.e. when the Theme’s ThemeData.brightness is Brightness.light, this color is used for disabled icons and for placeholder text in DataTable.

See also:

Source

pub const BLACK26: Color

Black with 26% opacity.

Used for disabled radio buttons and the text of disabled flat buttons in light themes.

See also:

  • ThemeData.disabledColor, which uses this color by default in light themes.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
  • BLACK, BLACK87, BLACK54, BLACK45, BLACK38, BLACK12, which are variants on this color but with different opacities.
Source

pub const BLACK12: Color

Black with 12% opacity.

Used for the background of disabled raised buttons in light themes.

See also:

Source

pub const WHITE: Color

Completely opaque white.

This is a good contrasting color for the ThemeData.primaryColor in the dark theme. See ThemeData.brightness.

See also:

  • Typography.white, which uses this color for its text styles.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
  • WHITE70, WHITE60, WHITE54, WHITE38, WHITE30, WHITE12, WHITE10, which are variants on this color but with different opacities.
  • BLACK, a solid black color.
  • TRANSPARENT, a fully-transparent color.
Source

pub const WHITE70: Color

White with 70% opacity.

This is a color commonly used for headings in dark themes.

See also:

  • Typography.white, which uses this color for its text styles.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
  • WHITE, WHITE60, WHITE54, WHITE38, WHITE30, WHITE12, WHITE10, which are variants on this color but with different opacities.
Source

pub const WHITE60: Color

White with 60% opacity.

Used for medium-emphasis text and hint text when ThemeData.brightness is set to Brightness.dark.

See also:

  • ExpandIcon, which uses this color for dark themes.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
  • WHITE, WHITE54, WHITE30, WHITE38, WHITE12, WHITE10, which are variants on this color but with different opacities.
Source

pub const WHITE54: Color

White with 54% opacity.

See also:

  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
  • WHITE, WHITE60, WHITE38, WHITE30, WHITE12, WHITE10, which are variants on this color but with different opacities.
Source

pub const WHITE38: Color

White with 38% opacity.

Used for disabled radio buttons and the text of disabled flat buttons in dark themes.

See also:

  • ThemeData.disabledColor, which uses this color by default in dark themes.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
  • WHITE, WHITE60, WHITE54, WHITE70, WHITE30, WHITE12, WHITE10, which are variants on this color but with different opacities.
Source

pub const WHITE30: Color

White with 30% opacity.

See also:

  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
  • WHITE, WHITE60, WHITE54, WHITE70, WHITE38, WHITE12, WHITE10, which are variants on this color but with different opacities.
Source

pub const WHITE24: Color

White with 24% opacity.

Used for the splash color for filled buttons.

See also:

Source

pub const WHITE12: Color

White with 12% opacity.

Used for the background of disabled raised buttons in dark themes.

See also:

Source

pub const WHITE10: Color

White with 10% opacity.

See also:

Source

pub const RED: MaterialColor

The red primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.red[400],
)

See also:

  • RED_ACCENT, the corresponding accent colors.
  • DEEP_ORANGE and PINK, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const RED_ACCENT: MaterialAccentColor

The red accent swatch.

Icon(
  Icons.widgets,
  color: Colors.redAccent[400],
)

See also:

  • RED, the corresponding primary colors.
  • DEEP_ORANGE_ACCENT and PINK_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const PINK: MaterialColor

The pink primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.pink[400],
)

See also:

  • PINK_ACCENT, the corresponding accent colors.
  • RED and PURPLE, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const PINK_ACCENT: MaterialAccentColor

The pink accent color swatch.

Icon(
  Icons.widgets,
  color: Colors.pinkAccent[400],
)

See also:

  • PINK, the corresponding primary colors.
  • RED_ACCENT and PURPLE_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const PURPLE: MaterialColor

The purple primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.purple[400],
)

See also:

  • PURPLE_ACCENT, the corresponding accent colors.
  • DEEP_PURPLE and PINK, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const PURPLE_ACCENT: MaterialAccentColor

The purple accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.purpleAccent[400],
)

See also:

  • PURPLE, the corresponding primary colors.
  • DEEP_PURPLE_ACCENT and PINK_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const DEEP_PURPLE: MaterialColor

The deep purple primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.deepPurple[400],
)

See also:

  • DEEP_PURPLE_ACCENT, the corresponding accent colors.
  • PURPLE and INDIGO, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const DEEP_PURPLE_ACCENT: MaterialAccentColor

The deep purple accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.deepPurpleAccent[400],
)

See also:

  • DEEP_PURPLE, the corresponding primary colors.
  • PURPLE_ACCENT and INDIGO_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const INDIGO: MaterialColor

The indigo primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.indigo[400],
)

See also:

  • INDIGO_ACCENT, the corresponding accent colors.
  • BLUE and DEEP_PURPLE, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const INDIGO_ACCENT: MaterialAccentColor

The indigo accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.indigoAccent[400],
)

See also:

  • INDIGO, the corresponding primary colors.
  • BLUE_ACCENT and DEEP_PURPLE_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const BLUE: MaterialColor

The blue primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.blue[400],
)

See also:

  • BLUE_ACCENT, the corresponding accent colors.
  • INDIGO, LIGHT_BLUE, and BLUE_GREY, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const BLUE_ACCENT: MaterialAccentColor

The blue accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.blueAccent[400],
)

See also:

  • BLUE, the corresponding primary colors.
  • INDIGO_ACCENT and LIGHT_BLUE_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const LIGHT_BLUE: MaterialColor

The light blue primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.lightBlue[400],
)

See also:

  • LIGHT_BLUE_ACCENT, the corresponding accent colors.
  • BLUE and CYAN, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const LIGHT_BLUE_ACCENT: MaterialAccentColor

The light blue accent swatch.

Icon(
  Icons.widgets,
  color: Colors.lightBlueAccent[400],
)

See also:

  • LIGHT_BLUE, the corresponding primary colors.
  • BLUE_ACCENT and CYAN_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const CYAN: MaterialColor

The cyan primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.cyan[400],
)

See also:

  • CYAN_ACCENT, the corresponding accent colors.
  • LIGHT_BLUE, TEAL, and BLUE_GREY, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const CYAN_ACCENT: MaterialAccentColor

The cyan accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.cyanAccent[400],
)

See also:

  • CYAN, the corresponding primary colors.
  • LIGHT_BLUE_ACCENT and TEAL_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const TEAL: MaterialColor

The teal primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.teal[400],
)

See also:

  • TEAL_ACCENT, the corresponding accent colors.
  • GREEN and CYAN, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const TEAL_ACCENT: MaterialAccentColor

The teal accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.tealAccent[400],
)

See also:

  • TEAL, the corresponding primary colors.
  • GREEN_ACCENT and CYAN_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const GREEN: MaterialColor

The green primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.green[400],
)

See also:

  • GREEN_ACCENT, the corresponding accent colors.
  • TEAL, LIGHT_GREEN, and LIME, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const GREEN_ACCENT: MaterialAccentColor

The green accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.greenAccent[400],
)

See also:

  • GREEN, the corresponding primary colors.
  • TEAL_ACCENT, LIGHT_GREEN_ACCENT, and LIME_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const LIGHT_GREEN: MaterialColor

The light green primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.lightGreen[400],
)

See also:

  • LIGHT_GREEN_ACCENT, the corresponding accent colors.
  • GREEN and LIME, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const LIGHT_GREEN_ACCENT: MaterialAccentColor

The light green accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.lightGreenAccent[400],
)

See also:

  • LIGHT_GREEN, the corresponding primary colors.
  • GREEN_ACCENT and LIME_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const LIME: MaterialColor

The lime primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.lime[400],
)

See also:

  • LIME_ACCENT, the corresponding accent colors.
  • LIGHT_GREEN and YELLOW, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const LIME_ACCENT: MaterialAccentColor

The lime accent primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.limeAccent[400],
)

See also:

  • LIME, the corresponding primary colors.
  • LIGHT_GREEN_ACCENT and YELLOW_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const YELLOW: MaterialColor

The yellow primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.yellow[400],
)

See also:

  • YELLOW_ACCENT, the corresponding accent colors.
  • LIME and AMBER, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const YELLOW_ACCENT: MaterialAccentColor

The yellow accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.yellowAccent[400],
)

See also:

  • YELLOW, the corresponding primary colors.
  • LIME_ACCENT and AMBER_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const AMBER: MaterialColor

The amber primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.amber[400],
)

See also:

  • AMBER_ACCENT, the corresponding accent colors.
  • YELLOW and ORANGE, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const AMBER_ACCENT: MaterialAccentColor

The amber accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.amberAccent[400],
)

See also:

  • AMBER, the corresponding primary colors.
  • YELLOW_ACCENT and ORANGE_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const ORANGE: MaterialColor

The orange primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.orange[400],
)

See also:

  • ORANGE_ACCENT, the corresponding accent colors.
  • AMBER, DEEP_ORANGE, and BROWN, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const ORANGE_ACCENT: MaterialAccentColor

The orange accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.orangeAccent[400],
)

See also:

  • ORANGE, the corresponding primary colors.
  • AMBER_ACCENT and DEEP_ORANGE_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const DEEP_ORANGE: MaterialColor

The deep orange primary color and swatch.

Icon(
  Icons.widgets,
  color: Colors.deepOrange[400],
)

See also:

  • DEEP_ORANGE_ACCENT, the corresponding accent colors.
  • ORANGE, RED, and BROWN, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const DEEP_ORANGE_ACCENT: MaterialAccentColor

The deep orange accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.deepOrangeAccent[400],
)

See also:

  • DEEP_ORANGE, the corresponding primary colors.
  • ORANGE_ACCENT RED_ACCENT, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const BROWN: MaterialColor

The brown primary color and swatch.

This swatch has no corresponding accent color and swatch.

Icon(
  Icons.widgets,
  color: Colors.brown[400],
)

See also:

  • ORANGE and BLUE_GREY, vaguely similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const GREY: MaterialColor

The grey primary color and swatch.

This swatch has no corresponding accent swatch.

This swatch, in addition to the values 50 and 100 to 900 in 100 increments, also features the special values 350 and 850. The 350 value is used for raised button while pressed in light themes, and 850 is used for the background color of the dark theme. See ThemeData.brightness.

Icon(
  Icons.widgets,
  color: Colors.grey[400],
)

See also:

Source

pub const BLUE_GREY: MaterialColor

The blue-grey primary color and swatch.

This swatch has no corresponding accent swatch.

Icon(
  Icons.widgets,
  color: Colors.blueGrey[400],
)

See also:

  • GREY, CYAN, and BLUE, similar colors.
  • Theme.of, which allows you to select colors from the current theme rather than hard-coding colors in your build methods.
Source

pub const PRIMARIES: &'static [MaterialColor]

The Material Design primary color swatches, excluding grey.

Source

pub const ACCENTS: &'static [MaterialAccentColor]

The Material Design accent color swatches.

Auto Trait Implementations§

§

impl Forget for Colors

§

impl Freeze for Colors

§

impl Move for Colors

§

impl RefUnwindSafe for Colors

§

impl Send for Colors

§

impl Sync for Colors

§

impl Unpin for Colors

§

impl UnsafeUnpin for Colors

§

impl UnwindSafe for Colors

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,