darken method

Color darken(
  1. double amount
)

Darken the shade of the color by the amount.

amount is a double between 0 and 1.

Based on: https://stackoverflow.com/a/60191441.

Implementation

Color darken(double amount) {
  assert(amount >= 0 && amount <= 1);

  final hsl = HSLColor.fromColor(this);
  return hsl
      .withLightness(
        clampDouble(hsl.lightness * (1 - amount), 0.0, 1.0),
      )
      .toColor();
}