fromHex static method
Converts a hex string (e.g., "#FFFFFF" or "FFFFFF") to a Color. Optionally supports alpha values (e.g., "#80FFFFFF" or "80FFFFFF").
Implementation
static Color fromHex(String hexString) {
final buffer = StringBuffer();
if (hexString.length == 6 || hexString.length == 7) {
buffer.write('ff'); // Default alpha value (fully opaque)
}
buffer.write(hexString.replaceFirst('#', ''));
return Color(int.parse(buffer.toString(), radix: 16));
}