shiftHsl static method
Shifts the lightness of a color in the HSL color space.
This method adjusts the lightness of the given Color by a specified amount.
The amt parameter specifies the amount to shift the lightness, where
positive values lighten the color and negative values darken it.
Parameters
c: The original Color to be adjusted.amt: The amount to shift the lightness. Default is0.
Returns
A new Color with the adjusted lightness.
Example
final lighterColor = ColorUtils.shiftHsl(Colors.green, 0.1); // Lighten by 10%.
final darkerColor = ColorUtils.shiftHsl(Colors.green, -0.1); // Darken by 10%.
Implementation
static Color shiftHsl(Color c, [double amt = 0]) {
var hslc = HSLColor.fromColor(c);
return hslc.withLightness((hslc.lightness + amt).clamp(0.0, 1.0)).toColor();
}