rest property Null safety

Stream<T> rest

Returns a stream of all the remaning events of the source stream.

All requested next, skip or take operations are completed first, and then any remaining events are provided as events of the returned stream.

Using rest closes this stream queue. After getting the rest the caller may no longer request other events, like after calling cancel.

Implementation

Stream<T> get rest {
  if (_isClosed) {
    throw _failClosed();
  }
  var request = _RestRequest<T>(this);
  _isClosed = true;
  _addRequest(request);
  return request.stream;
}