cancel method

void cancel(
  1. String taskId, [
  2. String reason = 'Cancelled by user'
])

Cancel a running or queued task.

Implementation

void cancel(String taskId, [String reason = 'Cancelled by user']) {
  final task = _tasks[taskId];
  if (task == null) return;

  task.cancel(reason);
  _queue.remove(taskId);
  _eventController.add(TaskCancelledEvent(taskId, reason));

  if (task.isRunning) {
    _runningCount--;
    _processQueue();
  }
}