swatchColor static method

List<String> swatchColor(
  1. String hex, {
  2. double percentage = 15,
  3. int amount = 5,
})

Swatch the given hex color.

It creates lighter and darker colors from the given hex returned in a list with the given hex.

The amount defines how much lighter or darker colors a generated. The specified percentage value defines the color spacing of the individual colors. As a default, each color is 15 percent lighter or darker than the previous one.

Implementation

static List<String> swatchColor(String hex,
    {double percentage = 15, int amount = 5}) {
  hex = fillUpHex(hex);

  var colors = <String>[];
  for (var i = 1; i <= amount; i++) {
    colors.add(shadeColor(hex, (6 - i) * percentage));
  }
  colors.add(hex);
  for (var i = 1; i <= amount; i++) {
    colors.add(shadeColor(hex, (0 - i) * percentage));
  }
  return colors;
}