isLightColor static method

bool isLightColor(
  1. Color color
)

Implementation

static bool isLightColor(Color color) {
  int red = hexToInt(color2HexStr(color).toString().substring(1, 3));
  int green = hexToInt(color2HexStr(color).toString().substring(3, 5));
  int blue = hexToInt(color2HexStr(color).toString().substring(5, 7));
  double darkness = 1 - (0.299 * red + 0.587 * green + 0.114 * blue) / 255;

  if (darkness < 0.5) {
    return true; // It's a light color
  } else {
    return false; // It's a dark color
  }
}