CancelableOperation<T>.fromFuture constructor

CancelableOperation<T>.fromFuture(Future<T> inner, { FutureOr onCancel() })

Creates a CancelableOperation wrapping inner.

When this operation is canceled, onCancel will be called and any value or error produced by inner will be discarded. If onCancel returns a Future, it will be forwarded to cancel.

onCancel will be called synchronously when the operation is canceled. It's guaranteed to only be called once.


factory CancelableOperation.fromFuture(Future<T> inner,
    {FutureOr onCancel()}) {
  var completer = CancelableCompleter<T>(onCancel: onCancel);
  return completer.operation;