parse static method

CSSLength? parse(
  1. String? value
)

Implementation

static CSSLength? 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;
  }

  var unit = parseCSSUnit(match.group(2), CSSUnit.px)!;

  return CSSLength(n, unit);
}