cancelAfter method

void cancelAfter(
  1. Duration delay
)

Schedules a Cancel operation on this CancellationTokenSource.

Implementation

void cancelAfter(Duration delay) {
  _throwIfDisposed();

  if (isCancellationRequested) {
    return;
  }

  if (delay == Duration.zero) {
    _state = _notifyingCompleteState;
  }

  _timer ??= Timer(delay, () => onTimer(this));
}