Stream<T>.fromIterable constructor
- Iterable<
T> elements
Creates a single-subscription stream that gets its data from elements
.
The iterable is iterated when the stream receives a listener, and stops
iterating if the listener cancels the subscription, or if the
Iterator.moveNext method returns false
or throws.
Iteration is suspended while the stream subscription is paused.
If calling Iterator.moveNext on elements.iterator
throws,
the stream emits that error and then it closes.
If reading Iterator.current on elements.iterator
throws,
the stream emits that error, but keeps iterating.
Implementation
factory Stream.fromIterable(Iterable<T> elements) {
return new _GeneratedStreamImpl<T>(
() => new _IterablePendingEvents<T>(elements));
}