toList method

Future<List<T>> toList()

Collects the data of this stream in a List.

Source

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/1.24.3/dart-async/Stream/toList.html