scan<S> method
Null safety
- S accumulator(
- S accumulated,
- T value,
- int index
- S seed
Applies an accumulator function over a Stream sequence and returns each intermediate result. The seed value is used as the initial accumulator value.
Example
Stream.fromIterable([1, 2, 3])
.scan((acc, curr, i) => acc + curr, 0)
.listen(print); // prints 1, 3, 6
Implementation
Stream<S> scan<S>(
S Function(S accumulated, T value, int index) accumulator, S seed) =>
transform(ScanStreamTransformer<T, S>(accumulator, seed));