onAccentFor static method

Color onAccentFor(
  1. Color c
)

Near-black or white, whichever has the higher WCAG contrast on c (a mid blue such as #0ea5e9 gets dark text: white would be 2.8:1).

Implementation

static Color onAccentFor(Color c) {
  const dark = Color(0xFF0B0D12);
  const light = Color(0xFFFFFFFF);
  return contrastRatio(dark, c) >= contrastRatio(light, c) ? dark : light;
}