cancel method

Future<bool> cancel()

Cancel the downloading, if deleteOnCancel is true then file will be deleted will return false if downloading was already finished or cancelled

Implementation

Future<bool> cancel() async {
  if (_doneOrCancelled) return false;
  _addEvent(TaskEvent(
      state: TaskState.canceled,
      bytesReceived: _bytesReceived,
      totalBytes: _totalBytes));
  await _subscription?.cancel();
  _subscription = null;
  _dispose(TaskState.canceled);
  return true;
}