ColorPalette.opposites constructor
- ColorPaletteBase<
dynamic, ColorModel> colorPalette, - {bool insertOpposites = true,
- bool growable = true,
- bool unique = false}
Generates a ColorPalette from colorPalette
by appending or
inserting the opposite colors of every color in colorPalette
.
Note: Use the opposite methods to flip every color in a palette to their respective opposites without preserving the original colors.
colorPalette
must not be null
.
If insertOpposites
is true
, the generated colors will be inserted
into the list of colors after their respective base colors. If false
,
the generated colors will be appended to the end of the list.
insertOpposites
defaults to true
and must not be null
.
If growable
is false
, a fixed-length the palette will be constructed
with a fixed-length list. If true
, a growable list will be used instead.
If unique
is false
, the palette will be constructed with a List.
If true
, a uniqueList
will be used instead.
Implementation
factory ColorPalette.opposites(
ColorPaletteBase colorPalette, {
bool insertOpposites = true,
bool growable = true,
bool unique = false,
}) {
final palette = <ColorModel>[];
if (!insertOpposites) palette.addAll(colorPalette.colors);
for (var i = 0; i < colorPalette.length; i++) {
final color = colorPalette[i];
if (insertOpposites) palette.add(color);
palette.add(color.opposite);
}
return ColorPalette(unique
? UniqueList<ColorModel>.from(palette, growable: growable)
: List<ColorModel>.from(palette, growable: growable));
}