parse static method

CSSColorRGB? parse(
  1. String color
)
override

Implementation

static CSSColorRGB? parse(String color) {
  var matchRGB = CSSColorRGB.patternRGB.firstMatch(color);
  if (matchRGB == null) return null;

  //var type = int.parse( match.group(1) ) ;
  var red = int.parse(matchRGB.group(2)!);
  var green = int.parse(matchRGB.group(3)!);
  var blue = int.parse(matchRGB.group(4)!);
  var alpha = parseDouble(matchRGB.group(5));

  if (alpha != null && alpha != 1) {
    return CSSColorRGBA(red, green, blue, alpha);
  } else {
    return CSSColorRGB(red, green, blue);
  }
}