await FlutterDownloader.enqueue(
url: Uri.parse(url).toString(),
savedDir: fullPath,
fileName: actualFileName,
showNotification: true,
openFileFromNotification: true,
saveInPublicStorage: true);
When deleting file from the file explorer and download the same file again always failing
In iOS it is working, Issue with android device only.
Steps:
- download a file (FlutterDownloader.enqueue())
- delete the file manually from downloads
- download the same file FlutterDownloader.enqueue())
Console Error: D/DownloadWorker(12373): Update notification: {notificationId: 8, title: GOA-1924573-2180476 (2).pdf, status: FAILED, progress: -1}
W/System.err(12373): java.lang.NullPointerException
W/System.err(12373): at vn.hunghd.flutterdownloader.DownloadWorker.downloadFile(DownloadWorker.kt:385)
W/System.err(12373): at vn.hunghd.flutterdownloader.DownloadWorker.doWork(DownloadWorker.kt:206)
W/System.err(12373): at androidx.work.Worker$1.run(Worker.java:86)
W/System.err(12373): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(12373): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(12373): at java.lang.Thread.run(Thread.java:919)
I/WM-WorkerWrapper(12373): Worker result FAILURE for Work [ id=4ef9a1d3-ff16-467f-b797-5fb7d3a981b5, tags={ flutter_download_task, vn.hunghd.flutterdownloader.DownloadWorker } ]
Anyone please help me to resolve this
Note: deleted file name and new download attempt file name same
I think this issue you are facing with the FlutterDownloader plugin on Android seems related to how the file deletion is handled. When you delete a file and then attempt to download the same file again, the FlutterDownloader might still be referencing the old file path which no longer exists, leading to a NullPointerException.
To resolve this issue, try the following steps