fc_file_picker_util 0.6.2 fc_file_picker_util: ^0.6.2 copied to clipboard
File pickers based on file_selector.
fc_file_picker_util #
Windows | macOS | iOS | Android | |
---|---|---|---|---|
Pick files | ✅ | ✅ | ✅ | ✅ |
Pick a folder | ✅ | ✅ | ✅ | ✅ |
Pick a save path | ✅ | ✅ | ❌ | ❌ |
fc_file_picker_util
is based on file_selector with the following differences:
- Support picking a folder on iOS, which returns a URL.
- Picking folder on macOS returns both path and URL.
- Picking folder on Android returns an SAF Uri (which supports both internal and external storage).
- For SAF APIs on Flutter, refer to saf_stream and saf_util.
Usage #
macOS #
You need to add the following key to entitlements in order for macOS app to be able to access file system:
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
Pick a file or multiple files #
/// Picks a file and return a
/// [XFile](https://pub.dev/documentation/cross_file/latest/cross_file/XFile-class.html).
/// If the user cancels the picker, it returns `null`.
final file = await FcFilePickerUtil.pickFile();
/// Picks multiple files and return a list of
/// [XFile](https://pub.dev/documentation/cross_file/latest/cross_file/XFile-class.html).
/// If the user cancels the picker, it returns `null`.
final files = await FcFilePickerUtil.pickMultipleFiles();
Pick a folder #
/// Picks a folder and return a [FcFilePickerXResult].
/// If the user cancels the picker, it returns `null`.
///
/// [writePermission] is only applicable on Android.
final folder = await FcFilePickerUtil.pickFolder(writePermission: true);
The result (FilePickerXResult
) can be a URI or path depending on the platform:
- Windows: path
- macOS: both URL and path are returned
- iOS: URL
- Note: you might need to call startAccessingSecurityScopedResource to gain access to the directory on iOS.
- Android: An SAF Uri
Pick a save path #
/// Picks a save file location and return a [String] path.
/// You can optionally specify a default file name via [defaultName].
/// If the user cancels the picker, it returns `null`.
final savePath = await FcFilePickerUtil.pickSaveFile();