fromColors static method

ColorPalette fromColors(
  1. Iterable<Color> colors, {
  2. PaletteWeights weights = const PaletteWeights(),
})

Builds a palette from an explicit list of colors.

Handy when colors were extracted elsewhere; every color receives a population of 1.

Implementation

static ColorPalette fromColors(
  Iterable<Color> colors, {
  PaletteWeights weights = const PaletteWeights(),
}) {
  final candidates = <int, int>{for (final c in colors) c.toARGB32(): 1};
  return fromPopulations(candidates, weights: weights);
}