saf

Saf

Saf

Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.

Currently supported features

  • Uses OS default native file explorer
  • Access the hidden folder and files
  • Accessing directories
  • Caching the files inside the app External files directory
  • Syncing the files of some directory with cached one
  • Different default type filtering (media, image, video, audio or any)
  • Support Android

If you have any feature that you want to see in this package, please feel free to issue a suggestion. 🎉

Example App

Android

Demo

Usage

To use this plugin, add saf as a dependency in your pubspec.yaml file.

Initiate Saf with instance

Saf saf = Saf("~/some/path")

Directory Permission request

bool? isGranted = await saf.getDirectoryPermission(isDynamic: false);

if (isGranted != null && isGranted) {
  // Perform some file operations
} else {
  // failed to get the permission
}

Get the list of all the paths for the Granted Directories


bool? directoriesPath = await saf.getPersistedPermissionDirectories();

Get paths of all the files for current directory


List<String>? paths = await saf.getFilesPath(FileType.media);

Cache the current directory


bool? isCached = await saf.cache();

if (isCached != null && isCached) {
  // Perform some file operations
} else {
  // failed to cache
}

Get the cached files' path for current directory


List<String>? cachedFilesPath = await saf.getCachedFilesPath();

Clear cache for the current directory


bool? isClear = await saf.clearCache();

Sync the current directory with the cached one


bool? isSynced = await saf.sync();

Release the persisted permission for current directory


bool? isReleased = await Saf.releasePersistedPermission();

Release the persisted permissions for all the granted directories


await Saf.releasePersistedPermissions();

Documentation

See the Saf Wiki for every detail on about how to install, setup and use it.

Saf Wiki

  1. Installation
  2. Setup
  3. API
  4. FAQ
  5. Troubleshooting

For full usage details refer to the Wiki above.

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Libraries

saf