toBytes method

Future<Uint8List> toBytes ()

Collects the data of this stream in a Uint8List.

Implementation

Future<Uint8List> toBytes() {
  var completer = new Completer<Uint8List>();
  var sink = new ByteConversionSink.withCallback(
      (bytes) => completer.complete(new Uint8List.fromList(bytes)));
  listen(sink.add,
      onError: completer.completeError,
      onDone: sink.close,
      cancelOnError: true);
  return completer.future;
}