Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - how to save a file on IOS

Tags:

ios

flutter

On Android I was able to download a pdf file inside the Downloads folder using the package downloads_path_provider, but on IOS I got an error using this package. If I use getApplicationDocumentsDirectory() I get the path: /var/mobile/Containers/Data/Application/EBB52CAB-7783-489A-B9C4-4BB7A093B8C3/Documents I want to put the download file inside the Files of an iphone enter image description here

like image 910
Rafael Honda Avatar asked Dec 27 '19 13:12

Rafael Honda


People also ask

How do I save files in downloads folder in flutter?

Show activity on this post. then use these 2 packages: permission_handler to request storage permission. downloads_path_provider to save the file in downloads directory.


Video Answer


1 Answers

you should use Path Provider instead for accessing more than just download directory on devices, it's official flutter plugin and it's easy to use.

For accessing Document directory on storage using the Path Provider use following:

 Directory documents = await getApplicationDocumentsDirectory();

this will allow you to store files in the document storage, you might need to add permission for accessing storage.

For android use :

 Directory documents = await getExternalStorageDirectory();

Keep in mind that both of the above directories are visible to user.

like image 108
Harshvardhan Joshi Avatar answered Sep 19 '22 21:09

Harshvardhan Joshi