In Flutter the Color class only accepts integers as parameters
Other wise we need to use names constructors fromARGB/fromRGBO
If we have the Hexa color code then we need to convert this hexa color code into int type color code.
Option 1:
This we can achive by replace "#" with 0XFF in Hexa string and create const color variable by
|
const color = const Color(0xff0276e8); |
Then we can use this value to any where.
Option 2:
Create a class which extends color class
|
class ColorUtil extends Color { ColorUtil(final String hexColor) : super(_getColorFromHex(hexColor)); |
and use this in any wdiget by
|
Color color=ColorUtil("#0276e8") |