pub struct ColorScheme { /* private fields */ }Expand description
{@template material_ui.color_scheme.ColorScheme} A set of 45 colors based on the Material spec that can be used to configure the color properties of most components. {@endtemplate}
§Colors in Material 3
{@macro material_ui.colors.colorRoles}
The main accent color groups in the scheme are primary, secondary,
and tertiary.
-
Primary colors are used for key components across the UI, such as the FAB, prominent buttons, and active states.
-
Secondary colors are used for less prominent components in the UI, such as filter chips, while expanding the opportunity for color expression.
-
Tertiary colors are used for contrasting accents that can be used to balance primary and secondary colors or bring heightened attention to an element, such as an input field. The tertiary colors are left for makers to use at their discretion and are intended to support broader color expression in products.
Each accent color group (primary, secondary and tertiary) includes ‘-Fixed’
‘-Dim’ color roles, such as primary_fixed and primary_fixed_dim. Fixed roles
are appropriate to use in places where Container roles are normally used,
but they stay the same color between light and dark themes. The ‘-Dim’ roles
provide a stronger, more emphasized color with the same fixed behavior.
The remaining colors of the scheme are composed of neutral colors used for backgrounds and surfaces, as well as specific colors for errors, dividers and shadows. Surface colors are used for backgrounds and large, low-emphasis areas of the screen.
Material 3 also introduces tone-based surfaces and surface containers.
They replace the old opacity-based model which applied a tinted overlay on
top of surfaces based on their elevation. These colors include: surface_bright,
surface_dim, surface_container_lowest, surface_container_low, surface_container,
surface_container_high, and surface_container_highest.
Many of the colors have matching ‘on’ colors, which are used for drawing
content on top of the matching color. For example, if something is using
primary for a background color, on_primary would be used to paint text
and icons on top of it. For this reason, the ‘on’ colors should have a
contrast ratio with their matching colors of at least 4.5:1 in order to
be readable. On ‘-FixedVariant’ roles, such as on_primary_fixed_variant,
also have the same color between light and dark themes, but compared
with on ‘-Fixed’ roles, such as on_primary_fixed, they provide a
lower-emphasis option for text and icons.
This example shows all Material ColorScheme roles in light and dark
brightnesses.
{@macro material_ui.dartpad_guide}
{@example /example/lib/color_scheme/color_scheme.0.dart#body}
§Setting Colors in Flutter
{@macro material_ui.colors.settingColors}
Implementations§
Source§impl ColorScheme
impl ColorScheme
Sourcepub fn new(
brightness: Brightness,
primary: Color,
on_primary: Color,
secondary: Color,
on_secondary: Color,
error: Color,
on_error: Color,
surface: Color,
on_surface: Color,
) -> ColorScheme
pub fn new( brightness: Brightness, primary: Color, on_primary: Color, secondary: Color, on_secondary: Color, error: Color, on_error: Color, surface: Color, on_surface: Color, ) -> ColorScheme
Create a ColorScheme instance from the given colors.
ColorScheme::from_seed can be used as a simpler way to create a full
color scheme derived from a single seed color.
For the color parameters that are nullable, it is still recommended that applications provide values for them. They are only nullable due to backwards compatibility concerns.
If a color is not provided, the closest fallback color from the given
colors will be used for it (e.g. primary_container will default
to primary). Material Design 3 makes use of these colors for many
component defaults, so for the best results the application should
supply colors for all the parameters. An easy way to ensure this is to
use ColorScheme::from_seed to generate a full set of colors.
During the migration to Material Design 3, if an app’s
ThemeData.useMaterial3 is false, then components will only
use the following colors for defaults:
primaryon_primarysecondaryon_secondaryerroron_errorsurfaceon_surface
DEPRECATED:
backgroundon_background
Sourcepub fn with_brightness(self, brightness: Brightness) -> ColorScheme
pub fn with_brightness(self, brightness: Brightness) -> ColorScheme
Dart ColorScheme(brightness:).
Sourcepub fn with_primary(self, primary: Color) -> ColorScheme
pub fn with_primary(self, primary: Color) -> ColorScheme
Dart ColorScheme(primary:).
Sourcepub fn with_on_primary(self, on_primary: Color) -> ColorScheme
pub fn with_on_primary(self, on_primary: Color) -> ColorScheme
Dart ColorScheme(onPrimary:).
Sourcepub fn with_primary_container(self, primary_container: Color) -> ColorScheme
pub fn with_primary_container(self, primary_container: Color) -> ColorScheme
Dart ColorScheme(primaryContainer:).
Sourcepub fn with_on_primary_container(
self,
on_primary_container: Color,
) -> ColorScheme
pub fn with_on_primary_container( self, on_primary_container: Color, ) -> ColorScheme
Dart ColorScheme(onPrimaryContainer:).
Sourcepub fn with_primary_fixed(self, primary_fixed: Color) -> ColorScheme
pub fn with_primary_fixed(self, primary_fixed: Color) -> ColorScheme
Dart ColorScheme(primaryFixed:).
Sourcepub fn with_primary_fixed_dim(self, primary_fixed_dim: Color) -> ColorScheme
pub fn with_primary_fixed_dim(self, primary_fixed_dim: Color) -> ColorScheme
Dart ColorScheme(primaryFixedDim:).
Sourcepub fn with_on_primary_fixed(self, on_primary_fixed: Color) -> ColorScheme
pub fn with_on_primary_fixed(self, on_primary_fixed: Color) -> ColorScheme
Dart ColorScheme(onPrimaryFixed:).
Sourcepub fn with_on_primary_fixed_variant(
self,
on_primary_fixed_variant: Color,
) -> ColorScheme
pub fn with_on_primary_fixed_variant( self, on_primary_fixed_variant: Color, ) -> ColorScheme
Dart ColorScheme(onPrimaryFixedVariant:).
Sourcepub fn with_secondary(self, secondary: Color) -> ColorScheme
pub fn with_secondary(self, secondary: Color) -> ColorScheme
Dart ColorScheme(secondary:).
Sourcepub fn with_on_secondary(self, on_secondary: Color) -> ColorScheme
pub fn with_on_secondary(self, on_secondary: Color) -> ColorScheme
Dart ColorScheme(onSecondary:).
Sourcepub fn with_secondary_container(self, secondary_container: Color) -> ColorScheme
pub fn with_secondary_container(self, secondary_container: Color) -> ColorScheme
Dart ColorScheme(secondaryContainer:).
Sourcepub fn with_on_secondary_container(
self,
on_secondary_container: Color,
) -> ColorScheme
pub fn with_on_secondary_container( self, on_secondary_container: Color, ) -> ColorScheme
Dart ColorScheme(onSecondaryContainer:).
Sourcepub fn with_secondary_fixed(self, secondary_fixed: Color) -> ColorScheme
pub fn with_secondary_fixed(self, secondary_fixed: Color) -> ColorScheme
Dart ColorScheme(secondaryFixed:).
Sourcepub fn with_secondary_fixed_dim(self, secondary_fixed_dim: Color) -> ColorScheme
pub fn with_secondary_fixed_dim(self, secondary_fixed_dim: Color) -> ColorScheme
Dart ColorScheme(secondaryFixedDim:).
Sourcepub fn with_on_secondary_fixed(self, on_secondary_fixed: Color) -> ColorScheme
pub fn with_on_secondary_fixed(self, on_secondary_fixed: Color) -> ColorScheme
Dart ColorScheme(onSecondaryFixed:).
Sourcepub fn with_on_secondary_fixed_variant(
self,
on_secondary_fixed_variant: Color,
) -> ColorScheme
pub fn with_on_secondary_fixed_variant( self, on_secondary_fixed_variant: Color, ) -> ColorScheme
Dart ColorScheme(onSecondaryFixedVariant:).
Sourcepub fn with_tertiary(self, tertiary: Color) -> ColorScheme
pub fn with_tertiary(self, tertiary: Color) -> ColorScheme
Dart ColorScheme(tertiary:).
Sourcepub fn with_on_tertiary(self, on_tertiary: Color) -> ColorScheme
pub fn with_on_tertiary(self, on_tertiary: Color) -> ColorScheme
Dart ColorScheme(onTertiary:).
Sourcepub fn with_tertiary_container(self, tertiary_container: Color) -> ColorScheme
pub fn with_tertiary_container(self, tertiary_container: Color) -> ColorScheme
Dart ColorScheme(tertiaryContainer:).
Sourcepub fn with_on_tertiary_container(
self,
on_tertiary_container: Color,
) -> ColorScheme
pub fn with_on_tertiary_container( self, on_tertiary_container: Color, ) -> ColorScheme
Dart ColorScheme(onTertiaryContainer:).
Sourcepub fn with_tertiary_fixed(self, tertiary_fixed: Color) -> ColorScheme
pub fn with_tertiary_fixed(self, tertiary_fixed: Color) -> ColorScheme
Dart ColorScheme(tertiaryFixed:).
Sourcepub fn with_tertiary_fixed_dim(self, tertiary_fixed_dim: Color) -> ColorScheme
pub fn with_tertiary_fixed_dim(self, tertiary_fixed_dim: Color) -> ColorScheme
Dart ColorScheme(tertiaryFixedDim:).
Sourcepub fn with_on_tertiary_fixed(self, on_tertiary_fixed: Color) -> ColorScheme
pub fn with_on_tertiary_fixed(self, on_tertiary_fixed: Color) -> ColorScheme
Dart ColorScheme(onTertiaryFixed:).
Sourcepub fn with_on_tertiary_fixed_variant(
self,
on_tertiary_fixed_variant: Color,
) -> ColorScheme
pub fn with_on_tertiary_fixed_variant( self, on_tertiary_fixed_variant: Color, ) -> ColorScheme
Dart ColorScheme(onTertiaryFixedVariant:).
Sourcepub fn with_error(self, error: Color) -> ColorScheme
pub fn with_error(self, error: Color) -> ColorScheme
Dart ColorScheme(error:).
Sourcepub fn with_on_error(self, on_error: Color) -> ColorScheme
pub fn with_on_error(self, on_error: Color) -> ColorScheme
Dart ColorScheme(onError:).
Sourcepub fn with_error_container(self, error_container: Color) -> ColorScheme
pub fn with_error_container(self, error_container: Color) -> ColorScheme
Dart ColorScheme(errorContainer:).
Sourcepub fn with_on_error_container(self, on_error_container: Color) -> ColorScheme
pub fn with_on_error_container(self, on_error_container: Color) -> ColorScheme
Dart ColorScheme(onErrorContainer:).
Sourcepub fn with_surface(self, surface: Color) -> ColorScheme
pub fn with_surface(self, surface: Color) -> ColorScheme
Dart ColorScheme(surface:).
Sourcepub fn with_on_surface(self, on_surface: Color) -> ColorScheme
pub fn with_on_surface(self, on_surface: Color) -> ColorScheme
Dart ColorScheme(onSurface:).
Sourcepub fn with_surface_dim(self, surface_dim: Color) -> ColorScheme
pub fn with_surface_dim(self, surface_dim: Color) -> ColorScheme
Dart ColorScheme(surfaceDim:).
Sourcepub fn with_surface_bright(self, surface_bright: Color) -> ColorScheme
pub fn with_surface_bright(self, surface_bright: Color) -> ColorScheme
Dart ColorScheme(surfaceBright:).
Sourcepub fn with_surface_container_lowest(
self,
surface_container_lowest: Color,
) -> ColorScheme
pub fn with_surface_container_lowest( self, surface_container_lowest: Color, ) -> ColorScheme
Dart ColorScheme(surfaceContainerLowest:).
Sourcepub fn with_surface_container_low(
self,
surface_container_low: Color,
) -> ColorScheme
pub fn with_surface_container_low( self, surface_container_low: Color, ) -> ColorScheme
Dart ColorScheme(surfaceContainerLow:).
Sourcepub fn with_surface_container(self, surface_container: Color) -> ColorScheme
pub fn with_surface_container(self, surface_container: Color) -> ColorScheme
Dart ColorScheme(surfaceContainer:).
Sourcepub fn with_surface_container_high(
self,
surface_container_high: Color,
) -> ColorScheme
pub fn with_surface_container_high( self, surface_container_high: Color, ) -> ColorScheme
Dart ColorScheme(surfaceContainerHigh:).
Sourcepub fn with_surface_container_highest(
self,
surface_container_highest: Color,
) -> ColorScheme
pub fn with_surface_container_highest( self, surface_container_highest: Color, ) -> ColorScheme
Dart ColorScheme(surfaceContainerHighest:).
Sourcepub fn with_on_surface_variant(self, on_surface_variant: Color) -> ColorScheme
pub fn with_on_surface_variant(self, on_surface_variant: Color) -> ColorScheme
Dart ColorScheme(onSurfaceVariant:).
Sourcepub fn with_outline(self, outline: Color) -> ColorScheme
pub fn with_outline(self, outline: Color) -> ColorScheme
Dart ColorScheme(outline:).
Sourcepub fn with_outline_variant(self, outline_variant: Color) -> ColorScheme
pub fn with_outline_variant(self, outline_variant: Color) -> ColorScheme
Dart ColorScheme(outlineVariant:).
Sourcepub fn with_shadow(self, shadow: Color) -> ColorScheme
pub fn with_shadow(self, shadow: Color) -> ColorScheme
Dart ColorScheme(shadow:).
Sourcepub fn with_scrim(self, scrim: Color) -> ColorScheme
pub fn with_scrim(self, scrim: Color) -> ColorScheme
Dart ColorScheme(scrim:).
Sourcepub fn with_inverse_surface(self, inverse_surface: Color) -> ColorScheme
pub fn with_inverse_surface(self, inverse_surface: Color) -> ColorScheme
Dart ColorScheme(inverseSurface:).
Sourcepub fn with_on_inverse_surface(self, on_inverse_surface: Color) -> ColorScheme
pub fn with_on_inverse_surface(self, on_inverse_surface: Color) -> ColorScheme
Dart ColorScheme(onInverseSurface:).
Sourcepub fn with_inverse_primary(self, inverse_primary: Color) -> ColorScheme
pub fn with_inverse_primary(self, inverse_primary: Color) -> ColorScheme
Dart ColorScheme(inversePrimary:).
Sourcepub fn with_surface_tint(self, surface_tint: Color) -> ColorScheme
pub fn with_surface_tint(self, surface_tint: Color) -> ColorScheme
Dart ColorScheme(surfaceTint:).
Sourcepub fn with_background(self, background: Color) -> ColorScheme
👎Deprecated: Use surface instead. This feature was deprecated after v3.18.0-0.1.pre.
pub fn with_background(self, background: Color) -> ColorScheme
Use surface instead. This feature was deprecated after v3.18.0-0.1.pre.
Dart ColorScheme(background:).
Sourcepub fn with_on_background(self, on_background: Color) -> ColorScheme
👎Deprecated: Use onSurface instead. This feature was deprecated after v3.18.0-0.1.pre.
pub fn with_on_background(self, on_background: Color) -> ColorScheme
Use onSurface instead. This feature was deprecated after v3.18.0-0.1.pre.
Dart ColorScheme(onBackground:).
Sourcepub fn with_surface_variant(self, surface_variant: Color) -> ColorScheme
👎Deprecated: Use surfaceContainerHighest instead. This feature was deprecated after v3.18.0-0.1.pre.
pub fn with_surface_variant(self, surface_variant: Color) -> ColorScheme
Use surfaceContainerHighest instead. This feature was deprecated after v3.18.0-0.1.pre.
Dart ColorScheme(surfaceVariant:).
Sourcepub fn from_seed(seed_color: Color) -> ColorSchemeFromSeedBuilder
pub fn from_seed(seed_color: Color) -> ColorSchemeFromSeedBuilder
Generate a ColorScheme derived from the given seedColor.
Using the seedColor as a starting point, a set of tonal palettes are
constructed. By default, the tonal palettes are based on the Material 3
Color system and provide all of the ColorScheme colors. These colors are
designed to work well together and meet contrast requirements for
accessibility.
If any of the optional color parameters are non-null they will be used in place of the generated colors for that field in the resulting color scheme. This allows apps to override specific colors for their needs.
Given the nature of the algorithm, the seedColor may not wind up as
one of the ColorScheme colors.
The dynamicSchemeVariant parameter creates different types of
DynamicSchemes, which are used to generate different styles of ColorSchemes.
By default, dynamicSchemeVariant is set to tonalSpot. A ColorScheme
constructed by dynamicSchemeVariant.tonalSpot has pastel palettes and
won’t be too “colorful” even if the seedColor has a high chroma value.
If the resulting color scheme is too dark, consider setting dynamicSchemeVariant
to DynamicSchemeVariant.fidelity, whose palettes match the seed color.
The contrastLevel parameter indicates the contrast level between color
pairs, such as primary and on_primary. 0.0 is the default (normal);
-1.0 is the lowest; 1.0 is the highest. From Material Design guideline, the
medium and high contrast correspond to 0.5 and 1.0 respectively.
This sample shows how to use ColorScheme::from_seed to create dynamic
color schemes with different DynamicSchemeVariants and different
contrast level.
{@macro material_ui.dartpad_guide}
{@example /example/lib/color_scheme/color_scheme.0.dart#body}
See also:
- https://m3.material.io/styles/color/the-color-system/color-roles, the Material 3 Color system specification.
- https://pub.dev/packages/material_color_utilities, the package used to generate the tonal palettes needed for the scheme.
The builder takes brightness, dynamic_scheme_variant and contrast_level; Dart’s
colour overrides are the with_* setters on the built scheme, since each replaces
only its own colour.
Sourcepub fn light() -> ColorScheme
pub fn light() -> ColorScheme
Create a light ColorScheme based on a purple primary color that matches the baseline Material 2 color scheme.
This constructor shouldn’t be used to update the Material 3 color scheme.
For Material 3, use ColorScheme::from_seed to create a color scheme
from a single seed color based on the Material 3 color system.
This example demonstrates how to create a color scheme similar to ColorScheme::light
using the ColorScheme::from_seed constructor:
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xff6200ee)).copyWith(
primaryContainer: const Color(0xff6200ee),
onPrimaryContainer: Colors.white,
secondaryContainer: const Color(0xff03dac6),
onSecondaryContainer: Colors.black,
error: const Color(0xffb00020),
onError: Colors.white,
),Sourcepub fn dark() -> ColorScheme
pub fn dark() -> ColorScheme
Create the dark color scheme that matches the baseline Material 2 color scheme.
This constructor shouldn’t be used to update the Material 3 color scheme.
For Material 3, use ColorScheme::from_seed to create a color scheme
from a single seed color based on the Material 3 color system.
Override the brightness property of ColorScheme::from_seed to create a
dark color scheme.
This example demonstrates how to create a color scheme similar to ColorScheme::dark
using the ColorScheme::from_seed constructor:
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xffbb86fc),
brightness: Brightness.dark,
).copyWith(
primaryContainer: const Color(0xffbb86fc),
onPrimaryContainer: Colors.black,
secondaryContainer: const Color(0xff03dac6),
onSecondaryContainer: Colors.black,
error: const Color(0xffcf6679),
onError: Colors.black,
),Sourcepub fn high_contrast_light() -> ColorScheme
pub fn high_contrast_light() -> ColorScheme
Create a high contrast ColorScheme based on a purple primary color that matches the baseline Material 2 color scheme.
This constructor shouldn’t be used to update the Material 3 color scheme.
For Material 3, use ColorScheme::from_seed to create a color scheme
from a single seed color based on the Material 3 color system. To create a
high-contrast color scheme, set contrastLevel to 1.0.
This example demonstrates how to create a color scheme similar to ColorScheme::high_contrast_light
using the ColorScheme::from_seed constructor:
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xff0000ba)).copyWith(
primaryContainer: const Color(0xff0000ba),
onPrimaryContainer: Colors.white,
secondaryContainer: const Color(0xff66fff9),
onSecondaryContainer: Colors.black,
error: const Color(0xff790000),
onError: Colors.white,
),Sourcepub fn high_contrast_dark() -> ColorScheme
pub fn high_contrast_dark() -> ColorScheme
Create a high contrast ColorScheme based on the dark baseline Material 2 color scheme.
This constructor shouldn’t be used to update the Material 3 color scheme.
For Material 3, use ColorScheme::from_seed to create a color scheme
from a single seed color based on the Material 3 color system.
Override the brightness property of ColorScheme::from_seed to create a
dark color scheme. To create a high-contrast color scheme, set
contrastLevel to 1.0.
This example demonstrates how to create a color scheme similar to ColorScheme::high_contrast_dark
using the ColorScheme::from_seed constructor:
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xffefb7ff),
brightness: Brightness.dark,
).copyWith(
primaryContainer: const Color(0xffefb7ff),
onPrimaryContainer: Colors.black,
secondaryContainer: const Color(0xff66fff9),
onSecondaryContainer: Colors.black,
error: const Color(0xff9b374d),
onError: Colors.white,
),Sourcepub fn from_swatch() -> ColorSchemeFromSwatchBuilder
pub fn from_swatch() -> ColorSchemeFromSwatchBuilder
Creates a color scheme from a MaterialColor swatch.
In Material 3, this constructor is ignored by ThemeData when creating
its default color scheme. Instead, ThemeData uses ColorScheme::from_seed
to create its default color scheme. This constructor shouldn’t be used
to update the Material 3 color scheme. It will be phased out gradually;
see https://github.com/flutter/flutter/issues/120064 for more details.
If ThemeData.useMaterial3 is false, then this constructor is used by
ThemeData to create its default color scheme.
Sourcepub fn brightness(&self) -> Brightness
pub fn brightness(&self) -> Brightness
The Brightness of this scheme.
Sourcepub fn primary(&self) -> Color
pub fn primary(&self) -> Color
The color displayed most frequently across your app’s screens and components.
Sourcepub fn on_primary(&self) -> Color
pub fn on_primary(&self) -> Color
A color that’s clearly legible when drawn on primary.
Sourcepub fn primary_container(&self) -> Color
pub fn primary_container(&self) -> Color
A color used for elements needing less emphasis than primary.
Sourcepub fn on_primary_container(&self) -> Color
pub fn on_primary_container(&self) -> Color
A color that’s clearly legible when drawn on primary_container.
To ensure that an app is accessible, a contrast ratio between
primary_container and on_primary_container of at least 4.5:1
is recommended. See
https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html.
Sourcepub fn primary_fixed(&self) -> Color
pub fn primary_fixed(&self) -> Color
A substitute for primary_container that’s the same color for the dark
and light themes.
Sourcepub fn primary_fixed_dim(&self) -> Color
pub fn primary_fixed_dim(&self) -> Color
A color used for elements needing more emphasis than primary_fixed.
Sourcepub fn on_primary_fixed(&self) -> Color
pub fn on_primary_fixed(&self) -> Color
A color that is used for text and icons that exist on top of elements having
primary_fixed color.
Sourcepub fn on_primary_fixed_variant(&self) -> Color
pub fn on_primary_fixed_variant(&self) -> Color
A color that provides a lower-emphasis option for text and icons than
on_primary_fixed.
Sourcepub fn secondary(&self) -> Color
pub fn secondary(&self) -> Color
An accent color used for less prominent components in the UI, such as filter chips, while expanding the opportunity for color expression.
Sourcepub fn on_secondary(&self) -> Color
pub fn on_secondary(&self) -> Color
A color that’s clearly legible when drawn on secondary.
Sourcepub fn secondary_container(&self) -> Color
pub fn secondary_container(&self) -> Color
A color used for elements needing less emphasis than secondary.
Sourcepub fn on_secondary_container(&self) -> Color
pub fn on_secondary_container(&self) -> Color
A color that’s clearly legible when drawn on secondary_container.
To ensure that an app is accessible, a contrast ratio between
secondary_container and on_secondary_container of at least 4.5:1 is
recommended. See
https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html.
Sourcepub fn secondary_fixed(&self) -> Color
pub fn secondary_fixed(&self) -> Color
A substitute for secondary_container that’s the same color for the dark
and light themes.
Sourcepub fn secondary_fixed_dim(&self) -> Color
pub fn secondary_fixed_dim(&self) -> Color
A color used for elements needing more emphasis than secondary_fixed.
Sourcepub fn on_secondary_fixed(&self) -> Color
pub fn on_secondary_fixed(&self) -> Color
A color that is used for text and icons that exist on top of elements having
secondary_fixed color.
Sourcepub fn on_secondary_fixed_variant(&self) -> Color
pub fn on_secondary_fixed_variant(&self) -> Color
A color that provides a lower-emphasis option for text and icons than
on_secondary_fixed.
Sourcepub fn tertiary(&self) -> Color
pub fn tertiary(&self) -> Color
A color used as a contrasting accent that can balance primary
and secondary colors or bring heightened attention to an element,
such as an input field.
Sourcepub fn on_tertiary(&self) -> Color
pub fn on_tertiary(&self) -> Color
A color that’s clearly legible when drawn on tertiary.
To ensure that an app is accessible, a contrast ratio between
tertiary and on_tertiary of at least 4.5:1 is recommended. See
https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html.
Sourcepub fn tertiary_container(&self) -> Color
pub fn tertiary_container(&self) -> Color
A color used for elements needing less emphasis than tertiary.
Sourcepub fn on_tertiary_container(&self) -> Color
pub fn on_tertiary_container(&self) -> Color
A color that’s clearly legible when drawn on tertiary_container.
To ensure that an app is accessible, a contrast ratio between
tertiary_container and on_tertiary_container of at least 4.5:1 is
recommended. See
https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html.
Sourcepub fn tertiary_fixed(&self) -> Color
pub fn tertiary_fixed(&self) -> Color
A substitute for tertiary_container that’s the same color for dark
and light themes.
Sourcepub fn tertiary_fixed_dim(&self) -> Color
pub fn tertiary_fixed_dim(&self) -> Color
A color used for elements needing more emphasis than tertiary_fixed.
Sourcepub fn on_tertiary_fixed(&self) -> Color
pub fn on_tertiary_fixed(&self) -> Color
A color that is used for text and icons that exist on top of elements having
tertiary_fixed color.
Sourcepub fn on_tertiary_fixed_variant(&self) -> Color
pub fn on_tertiary_fixed_variant(&self) -> Color
A color that provides a lower-emphasis option for text and icons than
on_tertiary_fixed.
Sourcepub fn error(&self) -> Color
pub fn error(&self) -> Color
The color to use for input validation errors, e.g. for an InputDecoration’s error text.
Sourcepub fn error_container(&self) -> Color
pub fn error_container(&self) -> Color
A color used for error elements needing less emphasis than error.
Sourcepub fn on_error_container(&self) -> Color
pub fn on_error_container(&self) -> Color
A color that’s clearly legible when drawn on error_container.
To ensure that an app is accessible, a contrast ratio between
error_container and on_error_container of at least 4.5:1 is
recommended. See
https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html.
Sourcepub fn on_surface(&self) -> Color
pub fn on_surface(&self) -> Color
A color that’s clearly legible when drawn on surface.
Sourcepub fn surface_variant(&self) -> Color
👎Deprecated: Use surfaceContainerHighest instead. This feature was deprecated after v3.18.0-0.1.pre.
pub fn surface_variant(&self) -> Color
Use surfaceContainerHighest instead. This feature was deprecated after v3.18.0-0.1.pre.
A color variant of surface that can be used for differentiation against
a component using surface.
Sourcepub fn surface_dim(&self) -> Color
pub fn surface_dim(&self) -> Color
A color that’s always darkest in the dark or light theme.
Sourcepub fn surface_bright(&self) -> Color
pub fn surface_bright(&self) -> Color
A color that’s always the lightest in the dark or light theme.
Sourcepub fn surface_container_lowest(&self) -> Color
pub fn surface_container_lowest(&self) -> Color
A surface container color with the lightest tone and the least emphasis relative to the surface.
Sourcepub fn surface_container_low(&self) -> Color
pub fn surface_container_low(&self) -> Color
A surface container color with a lighter tone that creates less emphasis
than surface_container but more emphasis than surface_container_lowest.
Sourcepub fn surface_container(&self) -> Color
pub fn surface_container(&self) -> Color
A recommended color role for a distinct area within the surface.
Surface container color roles are independent of elevation. They replace the old opacity-based model which applied a tinted overlay on top of surfaces based on their elevation.
Surface container colors include surface_container_lowest, surface_container_low,
surface_container, surface_container_high and surface_container_highest.
Sourcepub fn surface_container_high(&self) -> Color
pub fn surface_container_high(&self) -> Color
A surface container color with a darker tone. It is used to create more
emphasis than surface_container but less emphasis than surface_container_highest.
Sourcepub fn surface_container_highest(&self) -> Color
pub fn surface_container_highest(&self) -> Color
A surface container color with the darkest tone. It is used to create the most emphasis against the surface.
Sourcepub fn on_surface_variant(&self) -> Color
pub fn on_surface_variant(&self) -> Color
A color that’s clearly legible when drawn on surface_variant.
To ensure that an app is accessible, a contrast ratio between
surface_variant and on_surface_variant of at least 4.5:1 is
recommended. See
https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html.
Sourcepub fn outline(&self) -> Color
pub fn outline(&self) -> Color
A utility color that creates boundaries and emphasis to improve usability.
Sourcepub fn outline_variant(&self) -> Color
pub fn outline_variant(&self) -> Color
A utility color that creates boundaries for decorative elements when a 3:1 contrast isn’t required, such as for dividers or decorative elements.
Sourcepub fn inverse_surface(&self) -> Color
pub fn inverse_surface(&self) -> Color
A surface color used for displaying the reverse of what’s seen in the surrounding UI, for example in a SnackBar to bring attention to an alert.
Sourcepub fn on_inverse_surface(&self) -> Color
pub fn on_inverse_surface(&self) -> Color
A color that’s clearly legible when drawn on inverse_surface.
To ensure that an app is accessible, a contrast ratio between
inverse_surface and on_inverse_surface of at least 4.5:1 is
recommended. See
https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html.
Sourcepub fn inverse_primary(&self) -> Color
pub fn inverse_primary(&self) -> Color
An accent color used for displaying a highlight color on inverse_surface
backgrounds, like button text in a SnackBar.
Sourcepub fn surface_tint(&self) -> Color
pub fn surface_tint(&self) -> Color
A color used as an overlay on a surface color to indicate a component’s elevation.
Sourcepub fn background(&self) -> Color
👎Deprecated: Use surface instead. This feature was deprecated after v3.18.0-0.1.pre.
pub fn background(&self) -> Color
Use surface instead. This feature was deprecated after v3.18.0-0.1.pre.
A color that typically appears behind scrollable content.
Sourcepub fn on_background(&self) -> Color
👎Deprecated: Use onSurface instead. This feature was deprecated after v3.18.0-0.1.pre.
pub fn on_background(&self) -> Color
Use onSurface instead. This feature was deprecated after v3.18.0-0.1.pre.
A color that’s clearly legible when drawn on background.
To ensure that an app is accessible, a contrast ratio between
background and on_background of at least 4.5:1 is recommended. See
https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html.
Sourcepub fn copy_with(&self) -> ColorScheme
pub fn copy_with(&self) -> ColorScheme
Creates a copy of this color scheme with the given fields replaced by the non-null parameter values.
Every colour that falls back to another is filled with what it reads now, as Dart’s
copyWith passes this.primaryContainer on; the with_* setters then replace them.
Sourcepub fn lerp(a: &ColorScheme, b: &ColorScheme, t: f64) -> ColorScheme
pub fn lerp(a: &ColorScheme, b: &ColorScheme, t: f64) -> ColorScheme
Linearly interpolate between two ColorScheme objects.
{@macro dart.ui.shadow.lerp}
Sourcepub fn of(app: &mut App, context: BuildContext) -> ColorScheme
pub fn of(app: &mut App, context: BuildContext) -> ColorScheme
The ThemeData::color_scheme of the ambient Theme.
Equivalent to Theme::of(app, context).color_scheme.
Trait Implementations§
Source§impl Clone for ColorScheme
impl Clone for ColorScheme
Source§impl Debug for ColorScheme
impl Debug for ColorScheme
Source§impl Diagnosticable for ColorScheme
impl Diagnosticable for ColorScheme
Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Object.runtimeType as diagnostics print it: the last segment of
the Rust type path, without generic arguments.Source§fn identity_hash(&self) -> u64
fn identity_hash(&self) -> u64
Object.hashCode as diagnostics print it: the object’s address.Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Source§fn to_diagnostics_node(&self) -> DiagnosticableNode
fn to_diagnostics_node(&self) -> DiagnosticableNode
DiagnosticsNode::to_string_deep.Source§fn to_diagnostics_node_with(
&self,
name: Option<String>,
style: Option<DiagnosticsTreeStyle>,
) -> DiagnosticableNode
fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode
toDiagnosticsNode(name:, style:).Source§fn to_string(&self) -> String
fn to_string(&self) -> String
toString: a single-line description with properties and no
children. Read moreSource§fn to_string_at(&self, min_level: DiagnosticLevel) -> String
fn to_string_at(&self, min_level: DiagnosticLevel) -> String
toString(minLevel:).