Skip to content

Latest commit

 

History

History
68 lines (51 loc) · 2.47 KB

README.md

File metadata and controls

68 lines (51 loc) · 2.47 KB

fc_file_picker_util

pub package

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).

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
  • 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();