Collects the data of this stream in a Uint8List.
Source
Future<Uint8List> toBytes() { Completer<Uint8List> completer = new Completer<Uint8List>(); dynamic sink = new ByteConversionSink.withCallback((dynamic bytes) => completer.complete(new Uint8List.fromList(bytes))); listen(sink.add, onError: completer.completeError, onDone: sink.close, cancelOnError: true); return completer.future; }