filesystem_picker 1.0.3

Flutter Android iOS

FileSystem file or folder picker dialog. Allows the user to browse the file system and pick a folder or file.

FileSystem Picker #

FileSystem file or folder picker dialog.

Allows the user to browse the file system and pick a folder or file.

Getting Started #

In your flutter project add the dependency:

dependencies:
  ...
  filesystem_picker: ^1.0.3

Import package:

import 'package:filesystem_picker/filesystem_picker.dart';

Usage #

To open the dialog, use the asynchronous FilesystemPicker.open method. The method returns the path to the selected folder or file as a string. The method takes the following parameters:

  • context - widget tree context, required parameter;
  • rootDirectory - the root path to view the filesystem, required parameter;
  • rootName - specifies the name of the filesystem view root in breadcrumbs, by default "Storage";
  • fsType - specifies the type of filesystem view (folder and files, folder only or files only), by default FilesystemType.all;
  • pickText - specifies the text for the folder selection button (only for fsType = FilesystemType.folder);
  • permissionText - specifies the text of the message that there is no permission to access the storage, by default: "Access to the storage was not granted.";
  • title - specifies the text of the dialog title;
  • folderIconColor - specifies the folder icon color;
  • allowedExtensions - specifies a list of file extensions that will be displayed for selection, if empty - files with any extension are displayed. Example: ['.jpg', '.jpeg'];
  • fileTileSelectMode - specifies the mode for selecting the file item (checkmark on the right or whole tile), by default: checkmark;
  • requestPermission - specifies the callback to request storage permission, callers can use e.g. permission_handler.

Android permissions #

To access the filesystem in Android, you must specify access permissions in the AndroidManifest.xml file, for example:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Folder pick example #

String path = await FilesystemPicker.open(
  title: 'Save to folder',
  context: context,
  rootDirectory: rootPath,
  fsType: FilesystemType.folder,
  pickText: 'Save file to this folder',
  folderIconColor: Colors.teal,
);

File pick example #

String path = await FilesystemPicker.open(
  title: 'Open file',
  context: context,
  rootDirectory: rootPath,
  fsType: FilesystemType.file,
  folderIconColor: Colors.teal,
  allowedExtensions: ['.txt'],
  fileTileSelectMode: FileTileSelectMode.wholeTile,
);

9
likes
80
pub points
83%
popularity

FileSystem file or folder picker dialog. Allows the user to browse the file system and pick a folder or file.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

chentsov@gmail.com

License

BSD (LICENSE)

Dependencies

flutter, path

More

Packages that depend on filesystem_picker