firstWhereOrNull method

E? firstWhereOrNull(
  1. bool predicate(
    1. E element
    )
)

Returns the first element that satisfies the given predicate, or null if none found.

Implementation

E? firstWhereOrNull(bool Function(E element) predicate) {
  for (final element in this) {
    if (predicate(element)) return element;
  }
  return null;
}