darken static method

Color darken(
  1. Color color,
  2. [double amount = .1]
)

Adjust a color and make it darker.

Implementation

static Color darken(Color color, [double amount = .1]) {
  assert(amount >= 0 && amount <= 1, 'Needs to be in range');

  final hsl = HSLColor.fromColor(color);
  final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));

  return hslDark.toColor();
}