getBrightness method
Calculates the brightness of the color.
Brightness is calculated based on the weighted sum of the red, green, and blue components. This method returns a value between 0 (dark) and 255 (light), where higher values represent brighter colors.
Example:
Color color = Color(0xFF42A5F5);
double brightness = color.getBrightness();
print(brightness); // Output: 121.14 (indicating a darker color)
Implementation
double getBrightness() => (r * 299 + g * 587 + b * 114) / 1000;