toColor method
Parse string to Color
Implementation
Color toColor() {
Color color =
Color((math.Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
try {
String hexColor = replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "0xFF$hexColor";
}
if (hexColor.length == 10) {
color = Color(int.parse(hexColor));
}
} on Exception catch (e, s) {
errorLogsNS("toColor", e, s);
}
return color;
}