Skip to content

flutter-cavalry/fc_file_picker_util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

File pickers based on [file_selector].

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published