exists method

bool exists(
  1. T item, {
  2. EqualityChecker<T>? equalityChecker,
})

Returns true if the item exists in the iterable, otherwise returns false.

Implementation

bool exists(T item, {EqualityChecker<T>? equalityChecker}) {
  return any((T oldItem) {
    if (equalityChecker != null) {
      return equalityChecker(item, oldItem);
    }
    if (oldItem == item) return true;
    final bool hashCodeEquals = oldItem.hashCode == item.hashCode;
    final bool runtimeTypeEquals = oldItem.runtimeType == item.runtimeType;
    return hashCodeEquals && runtimeTypeEquals;
  });
}