toBytes method

Future<Uint8List> toBytes()

Implementation

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