attachCancellable method
Attaches a Cancellable to this token.
If this token isn't attached to any other cancellables, it will also attach itself to the merged tokens.
Implementation
@override
void attachCancellable(Cancellable cancellable) {
_updateCancellationStatus();
assert(
!isCancelled,
'Attampted to attach to a $runtimeType that has already been cancelled.\n'
'Before calling attach() you should check isCancelled.',
);
if (!isCancelled) {
if (_attachedCancellables.isEmpty) {
for (final CancellationToken token in _tokens) {
token.attachCancellable(this);
}
}
if (!_attachedCancellables.contains(cancellable)) {
_attachedCancellables.add(cancellable);
}
}
}