from static method

CSSNumber? from(
  1. Object? value
)
override

Implementation

static CSSNumber? from(Object? value) {
  if (value == null) return null;

  if (value is CSSNumber) return value;

  if (value is String) {
    var f = CSSFunction.parse(value);

    if (f != null) {
      if (f is CSSCalc && !f.hasOperation) {
        var calcNumber = CSSNumber.parse(f.a);
        if (calcNumber.toString() == f.a) {
          return calcNumber;
        }
      }

      return CSSNumber.fromFunction(f);
    } else {
      return CSSNumber.parse(value);
    }
  }

  return null;
}