I want to convert Hex color values to RGB color values. How do I do that? Sorry this question might be a bit short. but the meaning is exactly Because I haven’t seen these answers anywhere.
For example, HEX color value = "0xff4f6872" converts to RGB color value = (R:79 G:104 B:114).
I look forward to these answers, thank you.
3
Answers
0xff4f6872 isn‘t (R:79 G:104 B:114).
Here:
The built-in material Color class has properties that hold the color value of each color channel. You can use them to find the RGB (red, green blue) or even the RGBA (red, green, blue, alpha) value of a color.
You first need to create a color object for your hex color by putting the value inside the
Color()
method and add ‘0xff’ before the hex value.You can then access any of the properties you want and use/display them however you want
The best way to convert a hexadecimal color string to RGB color values in Flutter or Dart:
So, you can get:
red = 79, green = 104, blue = 114.