Transforms a Stream.
When a stream'sStream.transform method is invoked with aStreamTransformer, the stream calls thebind method on the providedtransformer. The resulting stream is then returned from theStream.transform method.
Conceptually, a transformer is simply a function fromStream toStreamthat is encapsulated into a class.
It is good practice to write transformers that can be used multiple times.
All other transforming methods onStream, such asStream.map,Stream.where orStream.expand can be implemented usingStream.transform. AStreamTransformer is thus very powerful but oftenalso a bit more complicated to use.
TheStreamTransformer.fromHandlers constructor allows passing separatecallbacks to react to events, errors, and the end of the stream.TheStreamTransformer.fromBind constructor creates aStreamTransformerwhosebind method is implemented by calling the function passed to theconstructor.
- Implementers
Constructors
- StreamTransformer(StreamSubscription<
T> onListen(Stream<S> stream,boolcancelOnError)) - Creates aStreamTransformer based on the given
onListencallback.constfactory - StreamTransformer.fromBind(Stream<
T> bind(Stream<S> )) - Creates aStreamTransformer based on a
bindcallback.factory - StreamTransformer.fromHandlers({voidhandleData(Sdata,EventSink<
T> sink)?,voidhandleError(Objecterror,StackTracestackTrace,EventSink<T> sink)?,voidhandleDone(EventSink<T> sink)?}) - Creates aStreamTransformer that delegates events to the given functions.factory
Properties
- hashCode→int
- The hash code for this object.no setterinherited
- runtimeType→Type
- A representation of the runtime type of the object.no setterinherited
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(
Invocationinvocation)→ dynamic - Invoked when a nonexistent method or property is accessed.inherited
- toString(
)→String - A string representation of this object.inherited
Operators
- operator ==(
Objectother)→bool - The equality operator.inherited
Static Methods
- castFrom<
SS,ST,TS,TT> (StreamTransformer< SS,ST> source)→StreamTransformer<TS,TT> - Adapts
sourceto be aStreamTransformer<TS, TT>.