darken method
Returns a darker shade of the current color.
This method darkens the color by the given factor. The factor should be between 0 and 1, where 0 is the original color and 1 is the darkest possible shade (black).
Example:
Color color = Color(0xFF42A5F5);
Color darkerColor = color.darken(0.2); // Darkens the color by 20%
Implementation
Color darken(double factor) {
assert(factor >= 0 && factor <= 1, 'Factor should be between 0 and 1');
return Color.fromARGB(
a.toInt(),
(r * (1 - factor)).toInt(),
(g * (1 - factor)).toInt(),
(b * (1 - factor)).toInt(),
);
}