matchingColor static method

Color matchingColor(
  1. Color color,
  2. Brightness brightness
)

Computes the color that matches with color and brightness.

Implementation

static Color matchingColor(Color color, Brightness brightness) {
  final double colorLuminance = color.computeLuminance();
  final Color foregroundColor = colorLuminance < 0.2 && brightness == Brightness.dark
      ? Color.alphaBlend(onBackgroundColor(color).withOpacity(0.49), color)
      : colorLuminance > 0.8 && brightness == Brightness.light
          ? Color.alphaBlend(onBackgroundColor(color).withOpacity(0.28), color)
          : color;
  return Color.alphaBlend(foregroundColor, color);
}