I want user to be able to store txt/doc/pdf file generated by flutter app wherever he/she wants on his/her phone. For example, if it were a webapp, this would be achieved by sending HTTP header Content-Disposition: attachment; filename=MyFileName.txt
. Is it possible at all in flutter application? I tried looking at url_launcher
, flutter_downloader
, flutter_webview_plugin
or flutter_web_browser
packages, but non of them offer relevant functionality. I would appreciate any tips regarding this issue.
Asked
Active
Viewed 1,382 times
0

altern
- 5,829
- 5
- 44
- 72
-
Looks like this might work: https://stackoverflow.com/a/61495252/50962 – altern Jun 20 '20 at 21:06
-
Nope, doesn't work – altern Jun 20 '20 at 21:20
1 Answers
1
Getting the directory
You can use flutter_file_dialog to get the user the choose the location with this code:
final params = SaveFileDialogParams(sourceFilePath: "path_of_file_to_save");
final filePath = await FlutterFileDialog.saveFile(params: params);
print(filePath);
Saving the file
For that just use path_provider : https://flutter.dev/docs/cookbook/persistence/reading-writing-files

Lulupointu
- 3,364
- 1
- 12
- 28
-
I am getting an exception that the source file is not found while I am specifying correct path from the root of the project registered in assets section of `pubspec.yaml`. does it have to be full device path? how is it possible to get one? btw, tbh, I don't really understand why I need to specify `sourceFilePath: "path_of_file_to_save"` if I am composing content after getting `filePath` anyway. – altern Jun 21 '20 at 17:23
-
Assets and local storage are two different things, see my response here: https://stackoverflow.com/a/62499275/5990125 – Lulupointu Jun 21 '20 at 17:45