collectBytesCancelable function

CancelableOperation<Uint8List> collectBytesCancelable (Stream<List<int>> source)

Collects an asynchronous sequence of byte lists into a single list of bytes.

Returns a CancelableOperation that provides the result future and a way to cancel the collection early.

If the source stream emits an error event, the collection fails and the returned future completes with the same error.

If any of the input data are not valid bytes, they will be truncated to an eight-bit unsigned value in the resulting list.

Implementation

CancelableOperation<Uint8List> collectBytesCancelable(
    Stream<List<int>> source) {
  return _collectBytes(
      source,
      (subscription, result) => new CancelableOperation.fromFuture(result,
          onCancel: subscription.cancel));
}