isCustomColor static method

bool isCustomColor(
  1. Color color,
  2. Map<ColorSwatch<Object>, String>? customSwatch
)

Check if a color is included in a custom color swatches.

Returns true if the color is a custom swatch, otherwise false.

Implementation

static bool isCustomColor(
    Color color, Map<ColorSwatch<Object>, String>? customSwatch) {
  if (customSwatch != null) {
    for (final ColorSwatch<Object> swatch in customSwatch.keys) {
      for (final int i in _indexPrimary) {
        if (swatch[i] == color || swatch[i]?.value == color.value) {
          return true; // Color found in a swatch, return true.
        }
      }
    }
  }
  // Did not find the given color in a custom swatch, return false.
  return false;
}