isHexColor method
Check if a string is a valid hexadecimal color.
Implementation
bool isHexColor() {
if (this == null) {
throw ArgumentError('string: $this');
}
if (this!.isEmpty) {
return false;
}
return RegExp(r'^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$').hasMatch(this!);
}