DoStreamTransformer<T> class

Invokes the given callback at the corresponding point the the stream lifecycle. For example, if you pass in an onDone callback, it will be invoked when the stream finishes emitting items.

This transformer can be used for debugging, logging, etc. by intercepting the stream at different points to run arbitrary actions.

It is possible to hook onto the following parts of the stream lifecycle:

  • onCancel
  • onData
  • onDone
  • onError
  • onListen
  • onPause
  • onResume

In addition, the onEach argument is called at onData, onDone, and onError with a Notification passed in. The Notification argument contains the Kind of event (OnData, OnDone, OnError), and the item or error that was emitted. In the case of onDone, no data is emitted as part of the Notification.

If no callbacks are passed in, a runtime error will be thrown in dev mode in order to "fail fast" and alert the developer that the transformer should be used or safely removed.


new Stream.fromIterable([1])
    .transform(new DoStreamTransformer(
      onData: print,
      onError: (e, s) => print("Oh no!"),
      onDone: () => print("Done")))
    .listen(null); // Prints: 1, "Done"


DoStreamTransformer({void onCancel(), void onData(T event), void onDone(), void onEach(Notification<T> notification), Function onError, void onListen(), void onPause(Future resumeSignal), void onResume()})
Constructs a StreamTransformer which will trigger any of the provided handlers as they occur.


hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


bind(Stream<T> stream) Stream<T>
Transforms the provided stream. [...]
cast<RS, RT>() StreamTransformer<RS, RT>
Provides a StreamTransformer<RS, RT> view of this stream transformer. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]