cancel abstract method

void cancel([
  1. String? message
])

Cancels the task. If the task is still pending, cancellation is effective immediately with a CancelledException. For a running ValueTask, cancellation is ignored and the task's ValueTask.value will eventually complete. For a running StreamTask, cancellation will be effective after receiving the next value and the task's StreamTask.stream will be closed. It should be noted that cancellation of running tasks will not be notified to platform workers. To give running tasks a chance to get notified of cancellation, a CancellationToken should be passed on to tasks at the time they are created.

Implementation

void cancel([String? message]);