LazyStream<T> class

A Stream wrapper that forwards to another Stream that's initialized lazily.

This class allows a concrete Stream to be created only once it has a listener. It's useful to wrapping APIs that do expensive computation to produce a Stream.

Inheritance
Available extensions

Constructors

LazyStream(FutureOr<Stream<T>> callback())
Creates a single-subscription Stream that calls callback when it gets a listener and forwards to the returned stream.

Properties

first Future<T>
The first element of this stream.
no setterinherited
firstOrNull Future<T?>

Available on Stream<T>, provided by the StreamExtensions extension

A future which completes with the first event of this stream, or with null.
no setter
hashCode int
The hash code for this object.
no setterinherited
isBroadcast bool
Whether this stream is a broadcast stream.
no setterinherited
isEmpty Future<bool>
Whether this stream contains any elements.
no setterinherited
last Future<T>
The last element of this stream.
no setterinherited
length Future<int>
The number of elements in this stream.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
single Future<T>
The single element of this stream.
no setterinherited

Methods

any(bool test(T element)) Future<bool>
Checks whether test accepts any element provided by this stream.
inherited
asBroadcastStream({void onListen(StreamSubscription<T> subscription)?, void onCancel(StreamSubscription<T> subscription)?}) Stream<T>
Returns a multi-subscription stream that produces the same events as this.
inherited
asyncExpand<E>(Stream<E>? convert(T event)) Stream<E>
Transforms each element into a sequence of asynchronous events.
inherited
asyncMap<E>(FutureOr<E> convert(T event)) Stream<E>
Creates a new stream with each data event of this stream asynchronously mapped to a new event.
inherited
asyncMapBuffer<S>(Future<S> convert(List<T>)) Stream<S>

Available on Stream<T>, provided by the AsyncMap extension

Like asyncMap but events are buffered until previous events have been processed by convert.
asyncMapSample<S>(Future<S> convert(T)) Stream<S>

Available on Stream<T>, provided by the AsyncMap extension

Like asyncMap but events are discarded while work is happening in convert.
asyncWhere(FutureOr<bool> test(T)) Stream<T>

Available on Stream<T>, provided by the Where extension

Discards events from this stream based on an asynchronous test callback.
audit(Duration duration) Stream<T>

Available on Stream<T>, provided by the RateLimit extension

Audit a single event from each duration length period where there are events on this stream.
buffer(Stream<void> trigger, {bool longPoll = true}) Stream<List<T>>

Available on Stream<T>, provided by the RateLimit extension

Buffers the values emitted on this stream and emits them when trigger emits an event.
cast<R>() Stream<R>
Adapt this stream to be a Stream<R>.
inherited
combineLatest<T2, S>(Stream<T2> other, FutureOr<S> combine(T, T2)) Stream<S>

Available on Stream<T>, provided by the CombineLatest extension

Combines the latest values from this stream with the latest values from other using combine.
combineLatestAll(Iterable<Stream<T>> others) Stream<List<T>>

Available on Stream<T>, provided by the CombineLatest extension

Combine the latest value emitted from the source stream with the latest values emitted from others.
concurrentAsyncExpand<S>(Stream<S> convert(T)) Stream<S>

Available on Stream<T>, provided by the AsyncExpand extension

Like asyncExpand but the convert callback may be called for an element before the Stream emitted by the previous element has closed.
concurrentAsyncMap<S>(FutureOr<S> convert(T)) Stream<S>

Available on Stream<T>, provided by the AsyncMap extension

Like asyncMap but the convert callback may be called for an element before processing for the previous element is finished.
contains(Object? needle) Future<bool>
Returns whether needle occurs in the elements provided by this stream.
inherited
debounce(Duration duration, {bool leading = false, bool trailing = true}) Stream<T>

Available on Stream<T>, provided by the RateLimit extension

Suppresses events with less inter-event spacing than duration.
debounceBuffer(Duration duration) Stream<List<T>>

Available on Stream<T>, provided by the RateLimit extension

Buffers values until this stream does not emit for duration then emits the collected values.
distinct([bool equals(T previous, T next)?]) Stream<T>
Skips data events if they are equal to the previous data event.
inherited
drain<E>([E? futureValue]) Future<E>
Discards all data on this stream, but signals when it is done or an error occurred.
inherited
elementAt(int index) Future<T>
Returns the value of the indexth data event of this stream.
inherited
every(bool test(T element)) Future<bool>
Checks whether test accepts all elements provided by this stream.
inherited
expand<S>(Iterable<S> convert(T element)) Stream<S>
Transforms each element of this stream into a sequence of elements.
inherited
firstWhere(bool test(T element), {T orElse()?}) Future<T>
Finds the first element of this stream matching test.
inherited
fold<S>(S initialValue, S combine(S previous, T element)) Future<S>
Combines a sequence of values by repeatedly applying combine.
inherited
followedBy(Stream<T> next) Stream<T>

Available on Stream<T>, provided by the Concatenate extension

Emits all values and errors from next following all values and errors from this stream.
forEach(void action(T element)) Future<void>
Executes action on each element of this stream.
inherited
handleError(Function onError, {bool test(dynamic error)?}) Stream<T>
Creates a wrapper Stream that intercepts some errors from this stream.
inherited
join([String separator = ""]) Future<String>
Combines the string representation of elements into a single string.
inherited
lastWhere(bool test(T element), {T orElse()?}) Future<T>
Finds the last element in this stream matching test.
inherited
listen(void onData(T)?, {Function? onError, void onDone()?, bool? cancelOnError}) StreamSubscription<T>
Adds a subscription to this stream.
override
listenAndBuffer() Stream<T>

Available on Stream<T>, provided by the StreamExtensions extension

Eagerly listens to this stream and buffers events until needed.
map<S>(S convert(T event)) Stream<S>
Transforms each element of this stream into a new stream event.
inherited
merge(Stream<T> other) Stream<T>

Available on Stream<T>, provided by the Merge extension

Merges values and errors from this stream and other in any order as they arrive.
mergeAll(Iterable<Stream<T>> others) Stream<T>

Available on Stream<T>, provided by the Merge extension

Merges values and errors from this stream and any stream in others in any order as they arrive.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pipe(StreamConsumer<T> streamConsumer) Future
Pipes the events of this stream into streamConsumer.
inherited
reduce(T combine(T previous, T element)) Future<T>
Combines a sequence of values by repeatedly applying combine.
inherited
sample(Stream<void> trigger, {bool longPoll = true}) Stream<T>

Available on Stream<T>, provided by the RateLimit extension

Emits the most recent new value from this stream when trigger emits an event.
scan<S>(S initialValue, FutureOr<S> combine(S soFar, T element)) Stream<S>

Available on Stream<T>, provided by the Scan extension

Emits a sequence of the accumulated values from repeatedly applying combine.
singleWhere(bool test(T element), {T orElse()?}) Future<T>
Finds the single element in this stream matching test.
inherited
skip(int count) Stream<T>
Skips the first count data events from this stream.
inherited
skipWhile(bool test(T element)) Stream<T>
Skip data events from this stream while they are matched by test.
inherited
slices(int length) Stream<List<T>>

Available on Stream<T>, provided by the StreamExtensions extension

Creates a stream whose elements are contiguous slices of this.
startWith(T initial) Stream<T>

Available on Stream<T>, provided by the Concatenate extension

Emits initial before any values or errors from the this stream.
startWithMany(Iterable<T> initial) Stream<T>

Available on Stream<T>, provided by the Concatenate extension

Emits all values in initial before any values or errors from this stream.
startWithStream(Stream<T> initial) Stream<T>

Available on Stream<T>, provided by the Concatenate extension

Emits all values and errors in initial before any values or errors from this stream.
switchLatest() Stream<T>

Available on Stream<Stream<T>>, provided by the SwitchLatest extension

Emits values from the most recently emitted Stream.
switchMap<S>(Stream<S> convert(T)) Stream<S>

Available on Stream<T>, provided by the Switch extension

Maps events to a Stream and emits values from the most recently created Stream.
take(int count) Stream<T>
Provides at most the first count data events of this stream.
inherited
takeUntil(Future<void> trigger) Stream<T>

Available on Stream<T>, provided by the TakeUntil extension

Takes values from this stream which are emitted before trigger completes.
takeWhile(bool test(T element)) Stream<T>
Forwards data events while test is successful.
inherited
tap(void onValue(T)?, {void onError(Object, StackTrace)?, void onDone()?}) Stream<T>

Available on Stream<T>, provided by the Tap extension

Taps into this stream to allow additional handling on a single-subscriber stream without first wrapping as a broadcast stream.
throttle(Duration duration, {bool trailing = false}) Stream<T>

Available on Stream<T>, provided by the RateLimit extension

Reduces the rate that events are emitted to at most once per duration.
timeout(Duration timeLimit, {void onTimeout(EventSink<T> sink)?}) Stream<T>
Creates a new stream with the same events as this stream.
inherited
toList() Future<List<T>>
Collects all elements of this stream in a List.
inherited
toSet() Future<Set<T>>
Collects the data of this stream in a Set.
inherited
toString() String
A string representation of this object.
inherited
transform<S>(StreamTransformer<T, S> streamTransformer) Stream<S>
Applies streamTransformer to this stream.
inherited
where(bool test(T event)) Stream<T>
Creates a new stream from this stream that discards some elements.
inherited
whereNotNull() Stream<T>

Available on Stream<T?>, provided by the WhereNotNull extension

Discards null events from this stream.
whereType<S>() Stream<S>

Available on Stream<T>, provided by the Where extension

Discards events from this stream that are not of type S.

Operators

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