isHexColor method

bool isHexColor(
  1. String? color
)

验证十六进制颜色值 (#RGB, #RGBA, #RRGGBB, #RRGGBBAA)

Implementation

bool isHexColor(String? color) {
  const pattern = r'^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$';
  return hasMatch(color, pattern);
}