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 f = 1 - amount;
  return Color.fromARGB(
    alpha,
    (red * f).round(),
    (green * f).round(),
    (blue * f).round(),
  );
}