selectMode function

String selectMode(
  1. String value,
  2. AstryxThemeMode mode
)

Selects the half of a light-dark() expression matching mode.

A value that is not a light-dark() expression is returned unchanged, so this is safe to apply to anything.

Implementation

String selectMode(String value, AstryxThemeMode mode) {
  final pair = parseLightDark(value);
  if (pair == null) return value;
  return mode == AstryxThemeMode.dark ? pair.dark : pair.light;
}