tryParse static method

CSSCalcValue? tryParse(
  1. RenderStyle renderStyle,
  2. String propertyName,
  3. String propertyValue
)

Implementation

static CSSCalcValue? tryParse(RenderStyle renderStyle, String propertyName, String propertyValue) {
  if (CSSFunction.isFunction(propertyValue, functionName: CALC)) {
    List<CSSFunctionalNotation> fns = CSSFunction.parseFunction(propertyValue);
    if (fns.isNotEmpty && fns.first.args.isNotEmpty) {
      assert(fns.first.args.length == 1, 'Calc parameters count must be = 1');
      final expression = fns.first.args.first;
      final _CSSCalcParser parser = _CSSCalcParser(propertyName, renderStyle, expression);
      CalcExpressionNode? node = parser.processCalcExpression();
      return CSSCalcValue(node);
    }
  }
  return null;
}