file_manager 1.0.0 icon indicating copy to clipboard operation
file_manager: ^1.0.0 copied to clipboard

FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to feel like part of the Flutter framework.

File Manager #

FileManager-Banner

GitHub GitHub code size in bytes GitHub top language GitHub language count GitHub tag (latest by date) GitHub issues

FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to feel like part of the Flutter framework.

Compatibility #

✅   Android
✅   Linux
❌   Windows (in progress)
❌   Web
❌   MacOS (active issue: MacOS support)
❌   iOS (active issue: iOS support)

Usage #

Make sure to check out examples for more details.

Installation #

Dependencies Add the following line to pubspec.yaml:

dependencies:
  file_manager: ^1.0.0

Give storage permission to application #

Android: Beside needing to add WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE to your android/app/src/main/AndroidManifest.xml.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxx.yyy">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
...
</manifest>

also add for Android 10

    <application
      android:requestLegacyExternalStorage="true"   
      ...

You also need Runtime Request Permission allow storage permission from app setting manually or you may use any package such as permission_handler.

Basic setup #

The complete example is available here.

Required parameter for FileManager are controller and builder

  • controller The controller updates value and notifies its listeners, and FileManager updates itself appropriately whenever the user modifies the path or changes the sort-type with an associated FileManagerController.
final FileManagerController controller = FileManagerController();
  • builder This function allows you to create custom widgets and retrieve a list of entities List<FileSystemEntity>.

Sample code #

FileManager(
    controller: controller,
    builder: (context, snapshot) {
    final List<FileSystemEntity> entities = snapshot;
      return ListView.builder(
        itemCount: entities.length,
        itemBuilder: (context, index) {
          return Card(
            child: ListTile(
              leading: FileManager.isFile(entities[index])
                  ? Icon(Icons.feed_outlined)
                  : Icon(Icons.folder),
              title: Text(FileManager.basename(entities[index])),
              onTap: () {
                if (FileManager.isDirectory(entities[index])) {
                    controller.openDirectory(entities[index]);   // open directory
                  } else {
                      // Perform file-related tasks.
                  }
              },
            ),
          );
        },
      );
  },
),

FileManager #

PropertiesDescription
loadingScreenFor the loading screen, create a custom widget. A simple Centered CircularProgressIndicator is provided by default.
emptyFolderFor an empty screen, create a custom widget.
controllerFor an empty screen, create a custom widget.
hideHiddenEntityHide the files and folders that are hidden.
builderThis function allows you to create custom widgets and retrieve a list of entities List<FileSystemEntity>.

FileManagerContoller #

PropertiesDescription
getSortedByThe sorting type that is currently in use is returned.
setSortedByis used to set the sorting type. SortBy{ name, type, date, size }.
getCurrentDirectoryGet current Directory
getCurrentPathGet current path, similar to [getCurrentDirectory].
setCurrentPathSet current directory path by providing String of path, similar to [openDirectory]. List<FileSystemEntity>.
isRootDirectoryreturn true if current directory is the root. false, if the current directory not on root of the stogare.
goToParentDirectoryJumps to the parent directory of currently opened directory if the parent is accessible.
openDirectoryOpen directory by providing Directory.
titleNotifierValueNotifier of the current directory's basename

Others #

PropertiesDescription
isFilecheck weather FileSystemEntity is File.
isDirectorycheck weather FileSystemEntity is Directory.
basenameGet the basename of Directory or File. Provide File, Directory or FileSystemEntity and returns the name as a String. If you want to hide the extension of a file, you may use optional parameter showFileExtension. ie controller.dirName(dir, true)
formatBytesConvert bytes to human readable size.[getCurrentDirectory].
setCurrentPathSet current directory path by providing String of path, similar to [openDirectory]. List<FileSystemEntity>.
getStorageListGet list of available storage in the device, returns an empty list if there is no storage List<Directory>
createFolderCreates the directory if it doesn't exist. Requires currentPath and Name of the Directory.

Example Example Example Example

Show some ❤️ and ⭐ the repo #

GitHub Repo stars GitHub forks GitHub followers

Project Created & Maintained By #

Contributions #

Contributions are welcomed!

If you feel that a hook is missing, feel free to open a pull-request.

For a custom-hook to be merged, you will need to do the following:

  • Describe the use-case.

  • Open an issue explaining why we need this hook, how to use it, ... This is important as a hook will not get merged if the hook doens't appeal to a large number of people.

  • If your hook is rejected, don't worry! A rejection doesn't mean that it won't be merged later in the future if more people shows an interest in it. In the mean-time, feel free to publish your hook as a package on https://pub.dev.

  • A hook will not be merged unles fully tested, to avoid breaking it inadvertendly in the future.

78
likes
140
pub points
90%
popularity

Publisher

unverified uploader

FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to feel like part of the Flutter framework.

Homepage
Repository (GitHub)

Documentation

Documentation
API reference

License

Icon for licenses.BSD-3-Clause (LICENSE)

Dependencies

flutter, path_provider

More

Packages that depend on file_manager