darken method

Color darken(
  1. [int amount = 10]
)

Darkens the color with the given integer percentage amount. Defaults to 10%.

Implementation

Color darken([int amount = 10]) {
  if (amount <= 0) return this;
  if (amount > 100) return Colors.black;
  final HSLColor hsl = HSLColor.fromColor(this);
  return hsl.withLightness(math.min(1, math.max(0, hsl.lightness - amount / 100))).toColor();
}