firstWhereOrNull method

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

finds item by test and returns it but returns null if it doesn't exist

Implementation

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