Flutter - how to save a file on IOS

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.


Get the path

For accessing the Document directory you should use a Flutter plugin for finding commonly used locations on the filesystem. The most popular is path_provider

iOS Files app

For download files in your app's folder inside the Files app on the user's device, you should update info.plist.

UISupportsDocumentBrowser (Boolean - iOS) Specifies that the app is a document-based app and uses the UIDocumentBrowserViewController class.

If this key is set to YES, the user can set the document browser’s default save location in Settings. Additionally, the local file provider grants access to all the documents in the app’s Documents directory. These documents appear in the Files app, and in a Document Browser. Users can open and edit these document in place.

This key is supported in iOS 11 and later.

For more information read the docs: https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW37

Tags:

Ios

Flutter