listenToStream<T> abstract method

StreamSubscription<T> listenToStream<T>(
  1. Stream<T> stream,
  2. void onData(
    1. T event
    ), {
  3. Function? onError,
  4. void onDone()?,
  5. bool? cancelOnError,
})

Returns a StreamSubscription which handles events from the stream using the provided onData, onError and onDone handlers.

Consult documentation for Stream.listen for more info.

If the returned StreamSubscription is cancelled manually (i.e. canceled before disposal of the parent object) Disposable will clean up the internal reference allowing the subscription to be garbage collected.

Neither parameter may be null.

Implementation

StreamSubscription<T> listenToStream<T>(
    Stream<T> stream, void onData(T event),
    {Function? onError, void onDone()?, bool? cancelOnError});