firstOrNullWhere method

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

Returns the first element matching the given predicate, or null if no such element was found.

var list = ['a', 'Test'];
var firstLong= list.firstOrNullWhere((e) => e.length > 1); // 'Test'
var firstVeryLong = list.firstOrNullWhere((e) => e.length > 5); // null

Implementation

E? firstOrNullWhere(bool Function(E element) predicate) {
  return firstWhereOrNull(predicate);
}