meetsWcagAaa function

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

Returns true when colors satisfy WCAG AAA contrast requirements.

largeText uses the WCAG relaxed threshold (4.5:1) for larger text sizes.

Implementation

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