colorWithOverlay static method

Color colorWithOverlay(
  1. Color surface,
  2. Color overlay,
  3. double elevation
)

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 applySurfaceTint, ThemeData.useMaterial3 for more information.

The opacity of the overlay depends on elevation. As elevation increases, the opacity will also increase.

See https://material-io.cn/design/color/dark-theme.html#properties.

Implementation

static Color colorWithOverlay(Color surface, Color overlay, double elevation) {
  return Color.alphaBlend(_overlayColor(overlay, elevation), surface);
}