CancelableCompleter<T> constructor

CancelableCompleter<T>({FutureOr onCancel() })

Creates a new completer for a CancelableOperation.

When the future operation canceled, as long as the completer hasn't yet completed, onCancel is called. If onCancel returns a Future, it's forwarded to CancelableOperation.cancel.

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

Implementation

CancelableCompleter({FutureOr onCancel()})
    : _onCancel = onCancel,
      _inner = new Completer<T>() {
  _operation = new CancelableOperation<T>._(this);
}