core/utils/theme_contrast_validator library

Classes

ContrastCheck
One pair to check — pure data, no NeonTheme dependency, so a caller (or a widget-fixture test, see this file's test) can validate arbitrary colors, not just the live theme.
ContrastIssue
A ContrastCheck that failed its threshold — ratio is either a WCAG contrast ratio (text/uiComponent/disabled) or an RGB Euclidean distance (gemPalette); both share the same "lower is worse" direction so a single < threshold comparison produces every issue.
ThemeContrastConfig
Thresholds — defaults are WCAG 2.1 AA. Pass a stricter ThemeContrastConfig (e.g. normalTextThreshold: 7.0 for AAA) to tighten the bar without touching validator code.

Enums

ContrastCheckKind
What a ContrastCheck/ContrastIssue is checking — each kind has its own natural threshold (WCAG normal text is stricter than a UI component's border, which is stricter than "disabled state must at least not be the exact same color as its background").

Functions

contrastRatio(Color a, Color b) → double
WCAG contrast ratio between 2 colors, always >= 1.0 regardless of argument order (https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio).
relativeLuminance(Color color) → double
WCAG relative luminance (https://www.w3.org/TR/WCAG21/#dfn-relative-luminance).
validateNeonThemeContrast({ThemeContrastConfig config = const ThemeContrastConfig()}) → List<ContrastIssue>
Validates the live NeonTheme across every state a consumer app can actually put it in — light/dark (NeonTheme.dark) crossed with the color-vision-deficiency-safe gem palette (NeonTheme.colorBlindSafe, see IDEA-38) — without leaving it mutated: both flags are restored to whatever they were before this call, in a finally, even if a caller passes a config that throws (it can't, but the guarantee holds either way).
validateNeonThemeContrastPairs(List<ContrastCheck> checks, {String state = 'default'}) → List<ContrastIssue>
Runs a fixed list of checks (each already carrying its own colors and threshold) and returns only the ones that failed, tagged with state for the report. Pure — no NeonTheme dependency; this is what a widget-fixture test or a caller with its own reskinned colors calls directly instead of validateNeonThemeContrast.