tryParse static method
Implementation
static CSSVariable? tryParse(RenderStyle renderStyle, 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.
dynamic defaultValue = fns.first.args.last.trim();
CSSVariable? defaultVar = CSSVariable.tryParse(renderStyle, defaultValue);
if (defaultVar != null) {
defaultValue = defaultVar;
}
return CSSVariable(fns.first.args.first, renderStyle, defaultValue: defaultValue);
} else {
return CSSVariable(fns.first.args.first, renderStyle);
}
}
}
return null;
}