expressionToColor static method

Color? expressionToColor(
  1. Expression? value
)

Implementation

static Color? expressionToColor(css.Expression? value) {
  if (value != null) {
    if (value is css.HexColorTerm) {
      return stringToColor(value.text);
    } else if (value is css.FunctionTerm) {
      if (value.text == 'rgba' || value.text == 'rgb') {
        return rgbOrRgbaToColor(value.span!.text);
      } else if (value.text == 'hsla' || value.text == 'hsl') {
        return hslToRgbToColor(value.span!.text);
      }
    } else if (value is css.LiteralTerm) {
      return namedColorToColor(value.text);
    }
  }
  return null;
}