withAlpha method

Color withAlpha(
  1. int a
)

Returns a new color that matches this color with the alpha channel replaced with a (which ranges from 0 to 255).

Out of range values will have unexpected effects.

Implementation

Color withAlpha(int a) {
  return Color.fromARGB(a, (r * 255.0).round() & 0xff,
      (g * 255.0).round() & 0xff, (b * 255.0).round() & 0xff);
}