Saf
A package that allows you to use the native file explorer and make it simple for users to get access for the documents, images, and other files across the directories on the go.
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. ?
Compatibility Chart
API | Android | iOS | Windows | linux | macOS |
---|---|---|---|---|---|
getDirectoryPermission() | ✅ | ❌ | ❌ | ❌ | ❌ |
getFilesPath() | ✅ | ❌ | ❌ | ❌ | ❌ |
getCachedFilesPath() | ✅ | ❌ | ❌ | ❌ | ❌ |
cache() | ✅ | ❌ | ❌ | ❌ | ❌ |
singleCache() | ✅ | ❌ | ❌ | ❌ | ❌ |
clearCache() | ✅ | ❌ | ❌ | ❌ | ❌ |
syncWithCacheDir() | ✅ | ❌ | ❌ | ❌ | ❌ |
getPersistedPermissionDirectories() | ✅ | ❌ | ❌ | ❌ | ❌ |
releasePersistedPermissions() | ✅ | ❌ | ❌ | ❌ | ❌ |
See the API section of the Saf Wiki or the official API reference on pub.dev for further details.
Documentation
See the Saf Wiki for every detail on about how to install, setup and use it.
Usage
Quick simple usage example:
Initiate Saf with instance
Saf saf = Saf(directoryPath: "~/some/path")
Directory Permission request
bool? isGranted = await saf.getDirectoryPermission(isDynamic: false);
if (isGranted != null) {
// Perform some file operations
} else {
// User canceled the native explorer
}
Get paths of all the files of granted directory
List<String>? paths = await saf.getFilesPath(FileType.media);
Cache the granted directory
List<String>? cachedFilesPath = await saf.cache();
Get the cached files’ path
List<String>? cachedFilesPath = await saf.getCachedFilesPath();
Cache a single file of the granted directory
String? path = await saf.singleCache(filePath: "~/some/path/file.type");
Clear cache of the granted directory
bool? isClear = await saf.clearCache();
Sync the cached directory with the granted directory
bool? isSynced = await saf.syncWithCacheDirectory();
Release the persisted permission for current granted directory
bool? isReleased = await saf.releasePersistedPermission();
Get the list of all the granted directory paths with persisted permissions
List<String>? paths = await Saf.getPersistedPermissionDirectories();
// Note: it is a static method
Release the persisted permissions for all granted the directories
bool? isReleased = await Saf.releasePersistedPermissions();
// Note: it is a static method
For full usage details refer to the Wiki above.
Example App
Android
Getting Started
For help getting started with Flutter, view our online documentation.
For help on editing plugin code, view the documentation.