CancelableOperation<T>.fromFuture constructor

CancelableOperation<T>.fromFuture(
  1. Future<T> inner,
  2. {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.

    Implementation

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