Collects all elements of this stream in a List.
Creates a List<T>
and adds all elements of the stream to the list in the order they arrive. When the stream ends, the returned future is completed with that list.
If the stream contains an error, the returned future is completed with that error, and processing stops.
Future<List<T>> toList() { List<T> result = <T>[]; _Future<List<T>> future = new _Future<List<T>>(); this.listen( (T data) { result.add(data); }, onError: future._completeError, onDone: () { future._complete(result); }, cancelOnError: true); return future; }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-async/Stream/toList.html