contrastRatio method

double contrastRatio(
  1. Color other
)

Calculates contrast ratio with another color

Implementation

double contrastRatio(Color other) {
  final l1 = computeLuminance();
  final l2 = other.computeLuminance();
  final lighter = math.max(l1, l2);
  final darker = math.min(l1, l2);
  return (lighter + 0.05) / (darker + 0.05);
}