StreamTransformer<S, T> class

Transforms a Stream.

When a stream's Stream.transform method is invoked with a StreamTransformer, the stream calls the bind method on the provided transformer. The resulting stream is then returned from the Stream.transform method.

Conceptually, a transformer is simply a function from Stream to Stream that is encapsulated into a class.

It is good practice to write transformers that can be used multiple times.

All other transforming methods on Stream, such as Stream.map, Stream.where or Stream.expand can be implemented using Stream.transform. A StreamTransformer is thus very powerful but often also a bit more complicated to use.

Implementers

Constructors

StreamTransformer(StreamSubscription<T> onListen(Stream<S> stream, bool cancelOnError))
const
factory
Creates a StreamTransformer based on the given onListen callback. [...]
StreamTransformer.fromBind(Stream<T> bind(Stream<S>))
factory
Creates a StreamTransformer based on a bind callback. [...]
StreamTransformer.fromHandlers({void handleData(S data, EventSink<T> sink), void handleError(Object error, StackTrace stackTrace, EventSink<T> sink), void handleDone(EventSink<T> sink)})
factory
Creates a StreamTransformer that delegates events to the given functions. [...]

Properties

hashCodeint
read-only, inherited
The hash code for this object. [...]
runtimeTypeType
read-only, inherited
A representation of the runtime type of the object.

Methods

bind(Stream<S> 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
inherited
Invoked when a non-existent method or property is accessed. [...]
toString() → String
inherited
A string representation of this object. [...]

Operators

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

Static Methods

castFrom<SS, ST, TS, TT>(StreamTransformer<SS, ST> source) → StreamTransformer<TS, TT>
Adapts source to be a StreamTransformer<TS, TT>. [...]

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-async/StreamTransformer-class.html