getColorFromHEX function
Implementation
Color getColorFromHEX(String? color) {
if (color == null) return Colors.transparent;
String hex = color.replaceAll("#", "");
if (hex.length == 3) {
// Convert 3-digit hex to 6-digit hex
hex = '${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}';
}
return Color(int.parse(hex, radix: 16) + 0xFF000000);
}