attachCancellable method
- @mustCallSuper
- Cancellable cancellable
Attaches a Cancellable
to this token.
Before attaching to a CancellationToken, you should check if it's already been cancelled by using isCancelled.
Implementation
@mustCallSuper
void attachCancellable(Cancellable cancellable) {
assert(
!isCancelled,
'Attampted to attach to a $runtimeType that has already been cancelled.\n'
'Check isCancelled or use the CancellableMixin\'s maybeAttach() method '
'to check if the token\'s already been cancelled before attaching to it.',
);
if (!isCancelled && !_attachedCancellables.contains(cancellable)) {
_attachedCancellables.add(cancellable);
}
}