throwIfCanceled method

void throwIfCanceled()

Throws the defined exception or CanceledException if no custom exception is defined in the default constructor, when cancellation has been requested earlier by calling cancel().

Implementation

void throwIfCanceled() {
  if (cancellationRequested) {
    throw _cancelException ?? CanceledException();
  }
}