singleOrNull property

T? get singleOrNull

Returns the single element of an iterator, null if this is empty or has more than one element.

Implementation

T? get singleOrNull {
  final firstTwo = _list.take(2).iterator;
  if (!firstTwo.moveNext()) {
    return null;
  }
  final first = firstTwo.current;
  if (!firstTwo.moveNext()) {
    return first;
  }
  return null;
}