parseHexColor function
'#RRGGBB' / 'RRGGBB' (or '#AARRGGBB') → Color; anything else → null.
Implementation
Color? parseHexColor(String s) {
var h = s.trim();
if (h.startsWith('#')) h = h.substring(1);
if (h.length == 6) h = 'FF$h';
if (h.length != 8) return null;
final v = int.tryParse(h, radix: 16);
return v == null ? null : Color(v);
}