tryParse static method

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

Implementation

static CSSVariable? tryParse(RenderStyle renderStyle, String propertyName, String propertyValue) {
  // font-size: var(--x);
  // font-size: var(--x, 28px);
  if (CSSFunction.isFunction(propertyValue, functionName: VAR)) {
    List<CSSFunctionalNotation> fns = CSSFunction.parseFunction(propertyValue);
    if (fns.first.args.isNotEmpty) {
      if (fns.first.args.length > 1) {
        // Has default value for CSS Variable.
        return CSSVariable(fns.first.args.first, renderStyle,
            defaultValue: fns.first.args.last);
      } else {
        return CSSVariable(fns.first.args.first, renderStyle);
      }
    }
  }
}