Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

file manager

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

properties description
loadingscreen for the loading screen, create a custom widget. a simple centered circularprogressindicator is provided by default.
emptyfolder for an empty screen, create a custom widget.
controller for an empty screen, create a custom widget.
hidehiddenentity hide the files and folders that are hidden.
builder this function allows you to create custom widgets and retrieve a list of entities list<filesystementity>.

filemanagercontoller

properties description
getsortedby the sorting type that is currently in use is returned.
setsortedby is used to set the sorting type. sortby{ name, type, date, size }.
getcurrentdirectory get current directory
getcurrentpath get current path, similar to [getcurrentdirectory].
setcurrentpath set current directory path by providing string of path, similar to [opendirectory]. list<filesystementity>.
isrootdirectory return true if current directory is the root. false, if the current directory not on root of the stogare.
gotoparentdirectory jumps to the parent directory of currently opened directory if the parent is accessible.
opendirectory open directory by providing directory.
titlenotifier valuenotifier of the current directory’s basename

others

properties description
isfile check weather filesystementity is file.
isdirectory check weather filesystementity is directory.
basename get 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)
formatbytes convert bytes to human readable size.[getcurrentdirectory].
setcurrentpath set current directory path by providing string of path, similar to [opendirectory]. list<filesystementity>.
getstoragelist get list of available storage in the device, returns an empty list if there is no storage list<directory>
createfolder creates the directory if it doesn’t exist. requires currentpath and name of the directory.

example
example
example
example


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.