getContrastColor static method

dynamic getContrastColor(
  1. Color color
)

Implementation

static getContrastColor(Color color) {
  double sum =
      (color.red * 0.299) + (color.green * 0.587) + (color.blue * 0.114);
  if (sum > 150) {
    return Colors.black;
  }
  return Colors.white;
}