darken property

ColorFilter darken
getter/setter pair

Makes the color darker by the percentage specified in the first argument, or by 10% if no percentage is specified. Percentages should be specified as a float, e.g. an argument of 0.25 will result in a color 25% darker than the original. The darkening conversion is performed by adjusting the y component of the color in XYZ color space.

Implementation

static ColorFilter darken = ColorFilter((Color inputColor, [List<num> args = const []]) {
  var color = inputColor.toCielabColor();
  num percent = 0.1;
  if (args.isNotEmpty) {
    percent = args[0];
  }
  return CielabColor(color.l * (1 - percent), color.a, color.b);
}, CielabColor);