blendAlpha method

Color blendAlpha(
  1. Color input, [
  2. int alpha = 0x0A
])

Blend in the given input Color with an alpha value.

You typically apply this on a background color, light or dark to create a background color with a hint of a color used in a theme.

This is a use case of the alphaBlend static function that exists in dart:ui Color. It is used to create the branded surface colors in ZetaColorScheme and to calculate dark scheme colors from light ones, by blending in white color with light scheme color.

Defaults to alpha 0x0A alpha blend of the passed in Color value, which is 10% alpha blend.

Implementation

Color blendAlpha(Color input, [int alpha = 0x0A]) {
  // Skip blending for impossible value and return the instance color value.
  if (alpha <= 0) return this;
  // Blend amounts >= 255 results in the input Color.
  if (alpha >= 255) return input;
  return Color.alphaBlend(input.withAlpha(alpha), this);
}