fromHex static method
- String hex
Implementation
static Color fromHex(String hex) {
hex = hex.replaceAll('#', '');
if (hex.length != 6) {
throw FormatException('Hex color should be 6 characters long.');
}
final r = int.parse(hex.substring(0, 2), radix: 16) / 255.0;
final g = int.parse(hex.substring(2, 4), radix: 16) / 255.0;
final b = int.parse(hex.substring(4, 6), radix: 16) / 255.0;
return Color(r, g, b);
}