from static method

CSSLength? from(
  1. Object? value
)
override

Implementation

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

  if (value is CSSLength) return value;

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

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

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

  return null;
}