cancellationSignal top-level property

Future<void>? get cancellationSignal

If this getter is called in a cancellation zone, returns a Future that completes once the operation is cancelled.

Note that the returned future might never complete (in case no cancellation is requested). Returns null if not running within a cancellation zone.

Implementation

Future<void>? get cancellationSignal {
  return switch (Zone.current[_key]) {
    CancellationToken(:final _cancellationCompleter) =>
      _cancellationCompleter.future,
    _ => null,
  };
}