useBlack function

bool useBlack({
  1. required Color color,
  2. double tolerance = 0.5,
})

useBlack is a helper function to detect if the color should have the content with Colors.White or Colors.black color. Will return a bool indicating if the color should be Colors.White or Colors.black.

Implementation

bool useBlack({required Color color, double tolerance = 0.5}) {
  final luminance = color.computeLuminance();
  return luminance > tolerance;
}