Download file to Device download folder in Flutter


I’m trying to download files in my flutter app using the dio plugin for which I have to specify a "savePath". But using path_provider I can only see ApplicationDocumentsDirectory, ExternalStorageDirectory etc. My idea is to simply show the file(pdf) in the device’s Download Folder, so whenever the user wants to view the file, he just goes to the folder and clicks it.
Saving to ApplicationDocumentsDirectory (as I understood it) would require me to provide a link (of sorts) to the file in the app, meaning the user would have to open my app every time he wants to view files downloaded through my app.

I just want the files to be available in the DownLoads Folder, just like with so many files we download directly to the DownLoads Folder.

Am I missing something here? pls enlighten me!

Added this code on request from user in comments:

var dir;
Future < dynamic > downloadFile(url, filename) async {
  Dio dio = Dio();

  try {
    //  checkPermission();
    dir = await getApplicationDocumentsDirectory();
    if (dir.path != null)
    if (await File("${dir.path}/$filename").exists()) {
      setState(() {

        filePath = "${dir.path}/$filename";
    await, "${dir.path}/$filename",
      onReceiveProgress: (rec, total) {
        print("Rec: $rec , Total: $total");

        setState(() {
          downloading = true;
          progressString = ((rec / total) * 100).toStringAsFixed(0) + "%";
  } catch (e) {

  setState(() {
    downloading = false;
    progressString = "Concluido";
    filePath = "${dir.path}/$filename";




You can use downloads_path_provider for it

import 'package:downloads_path_provider/downloads_path_provider.dart';  

Future<Directory> downloadsDirectory = DownloadsPathProvider.downloadsDirectory;

Answered By – Lucas Lima da Silva

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *