cancel method
Implementation
void cancel([String reason = 'cancelled']) {
if (_cancelled) return;
_cancelled = true;
_reason = reason;
final callbacks = List<void Function()>.of(_listeners);
_listeners.clear();
for (final callback in callbacks) {
try {
callback();
} catch (_) {
/* Continue releasing other resources. */
}
}
}