Starting with this string...

"color": "0xFF536DFE",

convert this string into a Color constant that could be used in a widget Color parameter?

something like this...

int hexValue = 0xFF536DFE;

I am doing it with some code, but I would image there to be a simpler way of doing this.


Solution 1: Günter Zöchbauer

You can't convert a string to a const hex value.

Dart limits what evaluations can be done at const creation time.

Not being able to use const sometimes isn't that much of a limitation. It might sum up if it affects a lot of values, but in general it's not a problem.