firstWhereOrNull method

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

Implementation

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