cancelTask method
If removeOnCancel
argument is provided,
FirefileController.removeOnCancel will be ignored for this task.
Else affects by FirefileController.removeOnCancel.
Implementation
void cancelTask(FirefileTask task, {bool? removeOnCancel}) async {
if (task.state == TaskState.running || task.state == TaskState.paused) {
task.uploadTask.cancel().ignore();
} else {
task.state = TaskState.canceled;
}
if (removeOnCancel ?? this.removeOnCancel) {
tasks.removeWhere((t) => t.fullPath == task.fullPath);
}
_bloc.add(FirefileEvent.updateTaskList(tasks, eventId: ++eventId));
}