TransformingConsumer<T> class abstract

Transforming operation that produces the original value unchanged, executing a given additional action.

class PrintConsumer extends TransformingConsumer<int> {
  @override
  void onAction(int value) {
    print("New value: ${value}");
  }
}

void main() async {
  final Stream<int> stream = Stream
    .fromIterable([1, 7, 2, 5])
    .transform(PrintConsumer());

  final List<String> values = await stream.toList();
  // New value: 1
  // New value: 7
  // New value: 2
  // New value: 5
  print(values);   // [1, 7, 2, 5]
}
Inheritance

Constructors

TransformingConsumer()
TransformingConsumer.parameter(void onAction(T))
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<T> stream) Stream<T>
Transforms the provided stream.
inherited
cast<RS, RT>() StreamTransformer<RS, RT>
Provides a StreamTransformer<RS, RT> view of this stream transformer.
inherited
dispose() Future<void>
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAction(T value) → void
onValue(T value) Iterable<T>
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited