How do I change color's hue, saturation, or value in Flutter?

Zenko

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

Tomas Baran

You can use these helper methods to change it. Just replace

  • newHueValue: with any double btw 0 and 360
  • newSaturationValue: with any double btw 0 and 1
  • newLightnessValue: with any double btw 0 and 1
Color 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.

edited at
0

Comments

0 comments
Login to comment

Related

How to specify a color with hue, saturation and brightness in libgdx

Given the numerical value of Hue, Saturation and Value, how to tell the name of color using a color wheel

How do i change the label's color in a BottomNavigationBarItem in Flutter?

How do change the color of subtext value in flutter

How to change color saturation of seaborn displot?

How do I change the check icon color in flutter filterChip

How do i change the color and text of Container at onTap event in FLUTTER

How do I change text selection handle color for iOS in Flutter?

How do I change the color of Flutter NavBar() icon?

Calculate color visibility from hue values respecting saturation and value in image numpy array

Hue adjustment maintaining same Saturation and Value

Flutter - How do I change a value straight after I setState

How do I change the color on my noUiSliders depending on the value it currently is at?

How do I change the color of an infobox in shinydashboard based on a string, not a value?

How do I change the color of GTK's "Dropdown"?

How do I change dynamically a background color of a WPF:s button

How do I change xterm's menu background color?

How do I change the scrollbar's color in Firefox?

How do I change the color of Firefox's menu bar?

How do I change one element's color on the hover of another?

How do I change only certain column's color?

How can I change text color accordingly to the change in value receiving from socket in flutter

How to change BottomNavigationBar item's color on Flutter?

How to change radio's inactive color in Flutter?

How to change the DropdownButton's icon color? Flutter

Matching the saturation value of a HSL color

How to change the chart line color to custom color code value in Flutter

How do i do multiple checks on a props value in order to change the color of that value. Inside of style={ }?

Flutter: How Do I Set a Container's Width to a Calculated Value?