firstWhereOrNull method

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

Returns first element by given predicate or null otherwise

Implementation

T? firstWhereOrNull(bool Function(T element) test) {
  if (this == null) return null;
  final list = this!.where(test);
  return list.isEmpty ? null : list.first;
}