parseColor static method
Parses a hex color string to a Color object.
Implementation
static Color parseColor(
String hexColor, {
Color defaultColor = Colors.black,
}) {
hexColor = hexColor.replaceAll('#', '');
if (hexColor.length == 6) {
hexColor = 'FF$hexColor';
}
try {
return Color(int.parse(hexColor, radix: 16));
} catch (e) {
return defaultColor;
}
}