cancel method

  1. @mustCallSuper
void cancel(
  1. [Exception? exception]

Cancels all operations using this token.

By default, the token will be cancelled with a CancelledException. To override this behaviour, pass a custom exception.

To include a reason for the cancellation, use cancelWithReason.


void cancel([Exception? exception]) {
  if (isCancelled) return;
  exception ??= const CancelledException();
  _cancelledException = exception;
  for (Cancellable cancellable in _attachedCancellables) {