firstWhereOrNull method

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

Returns the first element passing the given test, or null if no such element was found.

Implementation

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

  return null;
}