isPrimaryColor static method

bool isPrimaryColor(
  1. Color color
)

Check if the given color is included in any Material primary color swatch.

Returns true if the color is a Material primary color, otherwise false.

Implementation

static bool isPrimaryColor(Color color) {
  for (final ColorSwatch<Object> swatch in primaryColors) {
    for (final int i in _indexPrimaryWith850) {
      if (swatch[i] == color || swatch[i]?.value == color.value) {
        return true; // Color found in a swatch, return true.
      }
    }
  }
  // Color was not in any primary color swatch, return false.
  return false;
}