cancel method
Cancel this task
Returns true if the task was successfully canceled.
Returns false if the task was already completed or started.
Note: Tasks that have already started executing cannot be canceled. They will run to completion.
Implementation
bool cancel() {
if (isCanceled || _completer.isCompleted || isStarted) {
return false;
}
final wasCanceled = _onCancel?.call(_id) ?? false;
if (!wasCanceled) {
return false;
}
return _cancel();
}