firstWhereOrNull method Null safety

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

The first element satisfying test, or null if there are none.

Implementation

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