argbFromHex function
"aarrggbb" (or "#aarrggbb") → 0xAARRGGBB.
Implementation
int argbFromHex(Object? hex) {
if (hex is! String) throw FormatException('Expected colour hex: $hex');
final s = hex.startsWith('#') ? hex.substring(1) : hex;
final v = s.length == 8 ? int.tryParse(s, radix: 16) : null;
if (v == null) throw FormatException('Bad colour hex: $hex');
return v;
}