lighten method

Color lighten(
  1. double factor
)

Returns a lighter shade of the current color.

This method lightens the color by the given factor. The factor should be between 0 and 1, where 0 is the original color and 1 is the lightest possible shade (white).

Example:

Color color = Color(0xFF42A5F5);
Color lighterColor = color.lighten(0.2); // Lightens the color by 20%

Implementation

Color lighten(double factor) {
  assert(factor >= 0 && factor <= 1, 'Factor should be between 0 and 1');
  return Color.fromARGB(
    a.toInt(),
    (r + (255 - r) * factor).toInt(),
    (g + (255 - g) * factor).toInt(),
    (b + (255 - b) * factor).toInt(),
  );
}