Flutter color hex : How to use hex colors in Flutter?

All the developers will be quite familiar with the hexadecimal color format or hex color format for representing color. A color hex is specified with #RRGGBB. In flutter, color is defined using a Color class. The Flutter color class accepts an immutable 32-bit color value in ARGB format.

Define custom colors in Flutter

For example, coral color with a Hex triplet #FF7F50 can be defined in Flutter color format using a 32-bit color value in ARGB format as the example below. You just need to prefix it with 0XFF to set hex color in flutter.

Flutter color from ARGB

You can also use named constructors like fromARGB, fromRGBO to define the color like the example shown below:

Flutter color from hex string

If you need to use dynamic values of hexadecimal color or convert a hex string to Color, you can also define a custom class that extends Color class as shown below.

Interactive Example