blackAndWhiteSwatch static method

ColorSwatch<Object> blackAndWhiteSwatch(
  1. Color color
)

Returns a black or white color swatch for the color given to it.

If the color is a part of a black and white color swatch, then the Black or White color swatch will be returned. If the color is not in these swatches, it will create a primary material swatch for the given color using the given color as the mid 500 value and return this created custom primary color Swatch. This color swatch can then be used as a primary Material color swatch.

Implementation

static ColorSwatch<Object> blackAndWhiteSwatch(Color color) {
  for (final ColorSwatch<Object> swatch in blackAndWhite) {
    for (final int i in _indexPrimary) {
      if (swatch[i] == color || swatch[i]?.value == color.value) {
        return swatch; // Color found in a swatch, return it.
      }
    }
  }
  // Did not find the given color in a standard Material color swatch,
  // so make a custom material swatch based on the given color and return it.
  return createPrimarySwatch(color);
}