contrastRatio static method

double contrastRatio(
  1. dynamic lighterL,
  2. dynamic darkerL
)

Implementation

static double contrastRatio(lighterL, darkerL) {
  // https://www.w3.org/TR/WCAG20-TECHS/G18.html#G18-procedure
  var lighterY = Hsluv.lToY(lighterL);
  var darkerY = Hsluv.lToY(darkerL);
  return (lighterY + 0.05) / (darkerY + 0.05);
}