firstWhereOrNull method

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

Finds the first element satisfying the provided condition, or null if none is found.

Implementation

T? firstWhereOrNull(bool Function(T element) test) {
  for (var element in this) {
    if (test(element)) return element;
  }
  return null;
}