cancel method
- bool immediate = false,
Cancels the underlying event source.
If immediate
is false
(the default), the cancel operation waits until
all previously requested events have been processed, then it cancels the
subscription providing the events.
If immediate
is true
, the source is instead canceled
immediately. Any pending events are completed as though the underlying
stream had closed.
The returned future completes with the result of calling
cancel
on the subscription to the source stream.
After calling cancel
, no further events can be requested.
None of lookAhead, next, peek, rest, skip, take or cancel
may be called again.
Implementation
Future? cancel({bool immediate = false}) {
_checkNotClosed();
_isClosed = true;
if (!immediate) {
var request = _CancelRequest<T>(this);
_addRequest(request);
return request.future;
}
if (_isDone && _eventQueue.isEmpty) return Future.value();
return _cancel();
}