cancel method
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.
Implementation
@mustCallSuper
void cancel([Exception? exception]) {
if (isCancelled) return;
exception ??= const CancelledException();
_cancelledException = exception;
for (Cancellable cancellable in _attachedCancellables) {
cancellable.onCancel(exception);
}
_attachedCancellables.clear();
}