pub struct ElevationOverlay;Expand description
A utility class for dealing with the overlay color needed to indicate elevation of surfaces.
Dart’s abstract final class ElevationOverlay: it is never constructed, its members are
associated functions.
Implementations§
Source§impl ElevationOverlay
impl ElevationOverlay
Sourcepub fn apply_surface_tint(
color: Color,
surface_tint: Option<Color>,
elevation: f64,
) -> Color
pub fn apply_surface_tint( color: Color, surface_tint: Option<Color>, elevation: f64, ) -> Color
Applies a surface tint color to a given container color to indicate the level of its elevation.
With Material Design 3, some components will use a “surface tint” color overlay with an opacity applied to their base color to indicate they are elevated. The amount of opacity will vary with the elevation as described in: https://m3.material.io/styles/color/the-color-system/color-roles.
If surface_tint is not null and not completely transparent (Color::alpha
is 0), then the returned color will be the given color with the
surface_tint of the appropriate opacity applied to it. Otherwise it will
just return color unmodified.
Sourcepub fn apply_overlay(
app: &mut App,
context: BuildContext,
color: Color,
elevation: f64,
) -> Color
pub fn apply_overlay( app: &mut App, context: BuildContext, color: Color, elevation: f64, ) -> Color
Applies an overlay color to a surface color to indicate the level of its elevation in a dark theme.
If using Material Design 3, this type of color overlay is no longer used.
Instead a “surface tint” overlay is used instead. See apply_surface_tint,
ThemeData::use_material3 for more information.
Material drop shadows can be difficult to see in a dark theme, so the elevation of a surface should be portrayed with an “overlay” in addition to the shadow. As the elevation of the component increases, the overlay increases in opacity. This function computes and applies this overlay to a given color as needed.
If the ambient theme is dark (ThemeData::brightness is Brightness::Dark),
and ThemeData::apply_elevation_overlay_color is true, and the given
color is ColorScheme::surface then this will return a version of
the color with a semi-transparent ColorScheme::on_surface overlaid
on top of it. The opacity of the overlay is computed based on the
elevation.
Otherwise it will just return the color unmodified.
See also:
ThemeData::apply_elevation_overlay_colorwhich controls the whether an overlay color will be applied to indicate elevation.overlay_colorwhich computes the needed overlay color.Materialwhich uses this to apply an elevation overlay to its surface.- https://material.io/design/color/dark-theme.html, which specifies how the overlay should be applied.
Sourcepub fn overlay_color(
app: &mut App,
context: BuildContext,
elevation: f64,
) -> Color
pub fn overlay_color( app: &mut App, context: BuildContext, elevation: f64, ) -> Color
Computes the appropriate overlay color used to indicate elevation in dark themes.
If using Material Design 3, this type of color overlay is no longer used.
Instead a “surface tint” overlay is used instead. See apply_surface_tint,
ThemeData::use_material3 for more information.
See also:
- https://material.io/design/color/dark-theme.html#properties which specifies the exact overlay values for a given elevation.
Sourcepub fn color_with_overlay(
surface: Color,
overlay: Color,
elevation: f64,
) -> Color
pub fn color_with_overlay( surface: Color, overlay: Color, elevation: f64, ) -> Color
Returns a color blended by laying a semi-transparent overlay (using the
overlay color) on top of a surface (using the surface color).
If using Material Design 3, this type of color overlay is no longer used.
Instead a “surface tint” overlay is used instead. See apply_surface_tint,
ThemeData::use_material3 for more information.
The opacity of the overlay depends on elevation. As elevation
increases, the opacity will also increase.
See https://material.io/design/color/dark-theme.html#properties.