meetsWcagAa function

bool meetsWcagAa(
  1. Color foreground,
  2. Color background, {
  3. bool largeText = false,
  4. bool hasDarkBackground = true,
})

Returns true when colors satisfy WCAG AA contrast requirements.

largeText uses the WCAG relaxed threshold (3:1) for normal contrast checks on larger text sizes.

Implementation

bool meetsWcagAa(
  Color foreground,
  Color background, {
  bool largeText = false,
  bool hasDarkBackground = true,
}) {
  return contrastRatio(
        foreground,
        background,
        hasDarkBackground: hasDarkBackground,
      ) >=
      (largeText ? 3.0 : 4.5);
}