color method

Color color(
  1. BuildContext context
)

Implementation

Color color(BuildContext context) {
  var isDark = Theme.of(context).brightness == Brightness.dark;
  var hsl = HSLColor.fromColor(randomColor);
  if (isDark && hsl.lightness > 0.5) {
    return hsl.withLightness(0.5).toColor();
  } else if (!isDark && hsl.lightness < 0.5) {
    return hsl.withLightness(0.5).toColor();
  } else {
    return randomColor;
  }
}