parseLightDark function

AstryxColorValue? parseLightDark(
  1. String value
)

Parses a CSS light-dark(light, dark) expression into its two sides.

Returns null if value is not a light-dark() expression or does not contain a top-level comma.

Implementation

AstryxColorValue? parseLightDark(String value) {
  const prefix = 'light-dark(';
  final trimmed = value.trim();

  if (!trimmed.startsWith(prefix) || !trimmed.endsWith(')')) return null;

  final body = trimmed.substring(prefix.length, trimmed.length - 1);
  final split = splitTopLevelComma(body);
  if (split == null) return null;

  return AstryxColorValue(
    light: split.before.trim(),
    dark: split.after.trim(),
  );
}