tryParserCSSColorWithVariable static method

String tryParserCSSColorWithVariable(
  1. String fullColor,
  2. String input,
  3. RenderStyle renderStyle,
  4. String propertyName,
)

Implementation

static String tryParserCSSColorWithVariable(
    String fullColor, String input, RenderStyle renderStyle, String propertyName) {
  String replaced = input.replaceAllMapped(_variableRgbRegExp, (Match match) {
    String? varString = match[0];
    if (varString == null) return '';
    var variable = renderStyle.resolveValue(propertyName, varString);

    if (variable is CSSVariable) {
      String? resolved = renderStyle.getCSSVariable(variable.identifier, propertyName + '_' + fullColor)?.toString();

      return resolved ?? '';
    }
    return '';
  });

  return replaced;
}