cancelDownload method

  1. @override
Future<bool> cancelDownload(
  1. String url
)
override

Cancels a download in progress.

Implementation

@override
Future<bool> cancelDownload(String url) async {
  try {
    final result = await methodChannel.invokeMethod<bool>('cancelDownload', {
      'url': url,
    });

    // Close and remove the progress stream controller
    _closeProgressController(url);
    _closeInfoController(url);

    // Clear progress tracking
    _lastReportedProgress.remove(url);
    _lastReportedInfo.remove(url);

    return result ?? false;
  } catch (e) {
    debugPrint('Error canceling download: $e');
    return false;
  }
}