Suppose I have a Color object in Flutter that I want to change its Hue or Saturation or Lightness or Brightness, how do I do that?
Thanks
You can use these helper methods to change it. Just replace
newHueValue
: with any double btw 0 and 360newSaturationValue
: with any double btw 0 and 1newLightnessValue
: with any double btw 0 and 1Color changeColorHue(Color color) => HSLColor.fromColor(color).withHue(newHueValue).toColor();
Color changeColorSaturation(Color color) => HSLColor.fromColor(color).withSaturation(newSaturationValue).toColor();
Color changeColorLightness(Color color) => HSLColor.fromColor(color).withLightness(newLightnessValue).toColor();
Similarly you can use: HSVColor
for HSV (hue, saturation, value).
more: https://api.flutter.dev/flutter/painting/HSLColor-class.html
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments