Color.parse constructor
Color.parse(
- String? colorStr
Implementation
factory Color.parse(String? colorStr) {
if (colorStr == null) return Color(0);
colorStr = colorStr.trim();
if (RegExp(r'\d+\s*,\s*\d+\s*,\s*\d+').hasMatch(colorStr)) {
var parts = colorStr.split(RegExp(r'\D+'));
var r = int.parse(parts[0]);
var g = int.parse(parts[1]);
var b = int.parse(parts[2]);
return Color.fromARGB(0, r, g, b);
} else if (colorStr.startsWith('#')) {
return Color.fromHex(colorStr);
} else {
var argb = int.parse(colorStr);
return Color(argb);
}
}