parseCssColor function

Color? parseCssColor(
  1. String value,
  2. AstryxThemeMode mode
)

Parses a CSS colour to a Flutter Color.

Resolves a light-dark() wrapper for mode first, then accepts hex, rgb()/rgba(), the three named colours Astryx uses, and oklch() — which appears inside shadow values in some themes. Returns null for anything it cannot evaluate.

Implementation

Color? parseCssColor(String value, AstryxThemeMode mode) {
  final selected = selectMode(value, mode).trim();
  final rgba = parseColor(selected) ?? parseOklch(selected);
  return rgba == null ? null : toFlutterColor(rgba);
}