Detect color is light or dark in flutter
548
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
}else{
// color is dark
}
Author by
Noobdeveloper
Updated on December 30, 2022Comments
-
Noobdeveloper over 1 year
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