cancel method

Future<void> cancel()

Cancels the ongoing foreground download and recovery session (within the current object)

Do not use to cancel background downloads, return true from the background download callback to cancel a background download. Background download cancellations require a few more 'shut-down' steps that can create unexpected issues and memory leaks if not carried out.

Implementation

Future<void> cancel() async {
  _queue?.dispose();
  unawaited(_streamController?.close());
  unawaited(_progressManagement.stopTracking());

  if (_recoveryId != null) {
    await _storeDirectory.rootDirectory.recovery.cancel(_recoveryId!);
  }

  if (FlutterBackground.isBackgroundExecutionEnabled) {
    await FlutterBackground.disableBackgroundExecution();
  }
}