applySurfaceTint static method

Color applySurfaceTint(
  1. Color color,
  2. Color? surfaceTint,
  3. double elevation

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:

If surfaceTint is not null and not completely transparent (Color.alpha is 0), then the returned color will be the given color with the surfaceTint of the appropriate opacity applied to it. Otherwise it will just return color unmodified.


static Color applySurfaceTint(Color color, Color? surfaceTint, double elevation) {
  if (surfaceTint != null && surfaceTint != Colors.transparent) {
    return Color.alphaBlend(surfaceTint.withOpacity(_surfaceTintOpacityForElevation(elevation)), color);
  return color;