cancel method

void cancel([
  1. String reason = 'cancelled'
])

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. */
    }
  }
}