firstOrOption method

Option<T> firstOrOption()

Returns the first element of an iterator, None if empty.

Implementation

@pragma('vm:prefer-inline')
Option<T> firstOrOption() {
  final first = firstOrNull;
  if (first == null) {
    return None;
  }
  return Some(first);
}