firstWhereOrNull method

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

Returns the first value found by searching based on the condition specified in test.

If the value is not found, Null is returned.

Implementation

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