Executes action
on each data event of the stream.
Completes the returned Future
when all events of the stream
have been processed. Completes the future with an error if the
stream has an error event, or if action
throws.
Source
Future forEach(void action(T element)) { _Future future = new _Future(); StreamSubscription subscription; subscription = this.listen( (T element) { _runUserCode( () => action(element), (_) {}, _cancelAndErrorClosure(subscription, future) ); }, onError: future._completeError, onDone: () { future._complete(null); }, cancelOnError: true); return future; }