basedOnLuminance method

Color basedOnLuminance({
  1. Color darkColor = Colors.black,
  2. Color lightColor = Colors.white,
})

Get a constrast color based on the luminance of this color. If the luminance is bigger than 0.5, darkColor is used, otherwise lightColor is used.

This is usually used to constrast text colors with the background.

Implementation

Color basedOnLuminance({
  Color darkColor = Colors.black,
  Color lightColor = Colors.white,
}) {
  return computeLuminance() >= 0.5 ? darkColor : lightColor;
}