parseColor function
Implementation
Color? parseColor(String? colorStr) {
if (colorStr == null || colorStr.isEmpty) return null;
try {
if (colorStr.startsWith('#')) {
return Color(int.parse('0xFF${colorStr.substring(1)}'));
}
return Color(int.parse(colorStr));
} catch (e) {
debugPrint('Error parsing color: $e');
return Colors.blue; // Default fallback color
}
}