onCancel method

  1. @override
void onCancel(
  1. Exception cancelException, [
  2. StackTrace? stackTrace
])
override

Handles the cancellation of a merged token that this token is currently attached to.

Notifies all attached cancellables of the cancellation and detaches from the merged tokens.

Implementation

@override
void onCancel(Exception cancelException, [StackTrace? stackTrace]) {
  _isCancelled = true;
  _exception = cancelException;
  for (Cancellable cancellable in _attachedCancellables) {
    cancellable.onCancel(exception);
  }
  _attachedCancellables.clear();
  for (final CancellationToken token in _tokens) {
    token.detach(this);
  }
}