isHexColor function

bool isHexColor(
  1. String str
)

Checks if the string is a hexadecimal color.

Validates 3 or 6 digit hex colors, optional # prefix.

Example:

isHexColor('#fff'); // true
isHexColor('ff0000'); // true
isHexColor('#ff0000'); // true
isHexColor('invalid'); // false

Implementation

bool isHexColor(String str) => _isHexColor(str);