onCancelled method
- void callback()
Registers a callback to be called when this token is cancelled.
Returns a function that can be called to unregister the listener.
Implementation
void Function() onCancelled(void Function() callback) {
if (_isCancelled) {
callback();
return () {};
}
_listeners.add(callback);
return () => _listeners.remove(callback);
}