StreamBuilder<T> class

A mutable builder for a GenericStream.

This allows the creation of a GenericStream by generating elements individually and adding them to the builder (without the copying overhead that comes from using a List as a temporary buffer.)

A stream builder has a lifecycle, which starts in a building phase, during which elements can be added, and then transitions to a built phase, after which no more elements can be added. The built phase begins begins when the build method is called, which creates an ordered GenericStream whose elements are the elements that were added to the stream builder, in the order they were added.

Example Usage

final builder = StreamBuilder<String>();
builder.add('Hello');
builder.add('World');
final stream = builder.build();
print(stream.toList()); // ['Hello', 'World']
Annotations

Constructors

StreamBuilder()
A mutable builder for a GenericStream.

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

add(T element) StreamBuilder<T>
Adds an element to the stream being built.
addAll(Iterable<T> elements) StreamBuilder<T>
Adds all elements from the given iterable to the stream being built.
build() GenericStream<T>
Builds the stream, transitioning this builder to the built state. If there are further attempts to operate on the builder after it has entered the built state, NoGuaranteeException is thrown.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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