firstWhereOrNull method

T? firstWhereOrNull(
  1. bool test(
    1. T element
    ), {
  2. T orElse()?,
})

Implementation

T? firstWhereOrNull(bool Function(T element) test, {T Function()? orElse}) {
  int length = this.length;
  for (int i = 0; i < length; i++) {
    T element = this[i];
    if (test(element)) return element;
    if (length != this.length) {
      throw ConcurrentModificationError(this);
    }
  }
  if (orElse != null) return orElse();
  return null;
}