fromCssColor function

int fromCssColor(
  1. String color
)

Creates in int with a parsed Color value from a CSS color String.

Credits : https://pub.dev/packages/from_css_color - ported since dependency on dart:ui, here reimplemented without but with raw int.

Implementation

int fromCssColor(String color) {
  color = color.trim();

  switch (_recognizeCssColorFormat(color)) {
    case ColorFormat.hex:
      return _hexToColor(color);
    case ColorFormat.rgb:
    case ColorFormat.rgba:
      return _rgbToColor(color);
    case ColorFormat.keyword:
      return colorKeywords[color]!;
    default:
      return _hslToColor(color);
  }
}