I'm working on a project, that requires me to download a file from URL, once a button is tapped, and store it to phone storage (probably downloads folder).
Any ideas on how to do this? The file that is being downloaded is also not always the same and can be anything from an image to a pdf.
Use https://pub.dartlang.org/packages/flutter_downloader. Don't forget to do platform configurations.
Basically, this is how you should use the package. There is a detailed long example in the link.
final taskId = await FlutterDownloader.enqueue(
url: 'your download link',
savedDir: 'the path of directory where you want to save downloaded files',
showNotification: true, // show download progress in status bar (for Android)
openFileFromNotification: true, // click on notification to open downloaded file (for Android)
);
Edit: Some people said the package on top is not well maintained. Try this one https://pub.dev/packages/flowder