parse static method

CSSNumber? parse(
  1. String? value
)

Implementation

static CSSNumber? parse(String? value) {
  if (value == null) return null;

  var match = pattern.firstMatch(value);
  if (match == null) return null;

  var nStr = match.group(1);

  num? n;
  if (isInt(nStr)) {
    n = parseInt(nStr);
  } else if (isDouble(nStr)) {
    n = parseDouble(nStr);
  } else {
    return null;
  }

  return CSSNumber(n);
}