accentSwatch static method
Returns a Material accent color swatch for the color given to it.
If the color is a part of a standard material accent color swatch, then the standard accent color swatch will be returned.
If the color is not a Material standard accent color, creates a
material accent swatch for the given color using the given color
as 200
index value and return this created custom color accent swatch.
This color swatch can then be used as a accent Material color swatch.
Implementation
static MaterialAccentColor accentSwatch(Color color) {
for (final ColorSwatch<Object> swatch in accentColors) {
for (final int i in _indexAccent) {
if (swatch[i] == color || swatch[i]?.value32bit == color.value32bit) {
return swatch as MaterialAccentColor; // Found in a swatch, return it.
}
}
}
// Did not find the given color in a standard Material accent swatch, make
// a custom material accent swatch based on the given color and return it.
return createAccentSwatch(color);
}