Is there any way to check color is dark or ligh , in the sense black tone or white in flutter and get a boolean value true or false

Solution 1: Kartik Patel

To check whether color is dark or light, we will need to convert that color into its greyscale color. Formula to find grayscale of any color from its RGB value is:

grayscale = (0.299 * Red) + (0.587 * Green) + (0.114 * Blue)

And than check:

if(grayscale > 128){
    // color is light
    // color is dark

Solution 2: schlenger

You can also use the approach to take the luminance and apply the threshold specified by the W3C. In dart code this can look like this:

Color getFontColorForBackground(Color background) {
  return (background.computeLuminance() > 0.179)? : Colors.white;

More background information can be found here: