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

Overview

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.

Comments
  • Not compatible with flutter permission_handler above v9.2.0.

    Not compatible with flutter permission_handler above v9.2.0.

    When I set flutter permission_handler version to ^10.1.0 I get the following error:

    Because saf 1.0.3+3 depends on permission_handler ^9.2.0 and no versions of saf match >1.0.3+3 <2.0.0, saf ^1.0.3+3 requires permission_handler ^9.2.0.
    So, because myapp depends on both permission_handler ^10.1.0 and saf ^1.0.3+3, version solving failed.
    pub get failed (1; So, because myapp depends on both permission_handler ^10.1.0 and saf ^1.0.3+3, version solving failed.)
    exit code 1
    
    opened by markhorrocks 3
  • Can't use this folder to protect your privacy choose another folder ....!!!

    Can't use this folder to protect your privacy choose another folder ....!!!

    I am unable to access .statuses folder directly. When I click on the "grant button" it does not directly open the ,statuses folder and open the root directory and the "use this folder" button is unclickable. User have to open manually this folder to get access.

    here is the directory which I want to access: saf = Saf( '/storage/emulated/0/Android/media/com.whatsapp/WhatsApp/Media/.Statuses'); WhatsApp Image 2022-11-16 at 7 56 33 PM

    opened by HussnulMaab192 1
  • Incorrect dependencies

    Incorrect dependencies

    Running "flutter pub get" in appnote...
    Because every version of saf depends on permission_handler ^9.2.0 and appnote depends on permission_handler ^10.0.0, saf is forbidden. So, because appnote depends on saf ^1.0.3+3, version solving failed. pub get failed (1; So, because appnote depends on saf ^1.0.3+3, version solving failed.)

    opened by gorkovv 1
  • Exception - Permission Denial

    Exception - Permission Denial

    This exception appear when I try to open media directory

    Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsApp%2FMedia%2F.Statuses/document/primary%3AAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsApp%2FMedia%2F.Statuses/children from pid=32755, uid=10159 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs

    opened by AliAlHourash 1
  • Fix #14 & #19: upgrade permission_handler to ^10.2.0.0

    Fix #14 & #19: upgrade permission_handler to ^10.2.0.0

    Fix #14 & #19: upgrade permission_handler to ^10.2.0.0

    • update permission_handler dependencie from ^9.2.0 to ^10.2.0
    • change compileSdkVersion from 31 to 33 to be compatible with permission_handler
    opened by AMuellerAtAHS 0
  • A suggestion for simple usage

    A suggestion for simple usage

    Writing to external directory is required for certain cases and it gives too much complexities in achieving this.

    Play console does not allow apps to be published with "External manage" permissions, that is where SAF comes in.

    Now, my suggestion is simple. Why don't API allow an external root folder in the name of Application ID i.e. com.MyApp which is already unique to that App. Just like "GetApplicationsDocumentsDirectory", there can be "GetApplicationsRootDirectory" which always gives a folder based application ID with full access only to that App with the same appication ID.

    So any app from play store cannot access this folder (i.e. the security checking inside API can be made to achieve this). If possible attach the publisher's digital signature optionally to this.

    This method has only one issue. If a develper creates an App with some one else's Application ID and don't publish but some how installs manually in user's phone. This is not an issue actually because the App has not come from play store , so don't bother about security issues.

    opened by SampathNarayanan 0
  • How to sort list by date

    How to sort list by date

    Hi, I was wondering if we can sort the list of strings by their creation time or modified time. I'm making the use of cache method which returns list of string but it returns in the random order

    opened by superwebarmy 1
  • Sometimes files not getting in realme device (Android 11)

    Sometimes files not getting in realme device (Android 11)

    Saf saf = Saf("Android/media/com.whatsapp.w4b/WhatsApp Business/Media/.Statuses");
      bool? isSync = await saf.sync();
          if (isSync != null && isSync) {
            List<String>? _paths = await saf.getCachedFilesPath();
            if (_paths != null) {
              loadImage(_paths);
            }
    
     void loadImage(List<String> paths) {
        imageAssets = paths
            .map((item) => item)
            .where((item) => item.endsWith('.jpg'))
            .toList();
      }
    

    isSync getting null and _paths getting empty after 3-4 days from install app Other device working well but in realme device (Android 11) this problem happen.

    opened by prinsdha 0
  • Support for Android obb or data folder(commit from material files app)

    Support for Android obb or data folder(commit from material files app)

    Hello if possible can you add read or write access to data or obb folder. There is native File explorer that allows that here is commit for that. Thanks :D. https://github.com/zhanghai/MaterialFiles/commit/e356a9c5dc3f60d24a950e3d6f42018bf522c3e1

    opened by VirtualAstronaut 0
  • Can't the saf.sync() function copy files from the cache folder to android/data/xxx? Then how is it different from saf.cache()?

    Can't the saf.sync() function copy files from the cache folder to android/data/xxx? Then how is it different from saf.cache()?

    I want to copy the files from the cache to the directory after modifying them. But asf.sync() doesn't work. It just copies the files in directory to cache. what should I do?

    opened by jethroHuang 1
Owner
Vehement
Vehement ❤️ Open Source
Vehement
A basic template of Flutter to get started. Includes various folders and packages that might be necessary.

Flutter App - Basic Template It's a time saving template with basic project structure, packages and other files like constants.dart to get started rat

Muhammad Hamza 47 Jun 12, 2022
A basic template of Flutter to get started. Includes various folders and packages that might be necessary.

Flutter App - Basic Template It's a time saving template with basic project structure, packages and other files like constants.dart to get started rat

Muhammad Hamza 47 Jun 12, 2022
Download files from Firebase Storage with Flutter. List all images, videos, or other files from Firebase and download them.

Flutter Tutorial - Download Files From Firebase Storage Download files from Firebase Storage with Flutter. List all images, videos, or other files fro

Johannes Milke 28 Dec 4, 2022
Upload Files To Firebase Storage with Flutter. Pick images, videos, or other files from your device and upload them to Firebase.

Flutter Tutorial - Upload Files To Firebase Storage Upload Files To Firebase Storage with Flutter. Pick images, videos, or other files from your devic

Johannes Milke 30 Dec 28, 2022
Implementing simple storage operations, CRUD (Create, Read, Update, Delete), using Firebase Firestore

CRUD Firebase Implementing simple storage operations, CRUD (Create, Read, Update

Luciano Martins 6 Oct 29, 2022
A fast, extra light and synchronous key-value storage to Get framework

get_storage A fast, extra light and synchronous key-value in memory, which backs up data to disk at each operation. It is written entirely in Dart and

Jonny Borges 257 Dec 21, 2022
Get or set persistent storage value based on MMKV framework.

mmkv_flutter Plugin that allow Flutter to read value from persistent storage or save value to persistent storage based on MMKV framework Getting Start

OpenFlutter 101 Jan 17, 2022
Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps

Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps. Includes a TextInputFormatter to allow real-time AsYouType formatting.

Bottlepay 43 Nov 2, 2022
A freelancer project: A flutter app to manage files and certificates of employees in an organization. It uses AWS for authentication, Storage and DynamoDB.

certify A Certificate Management project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

null 0 Feb 3, 2022
System info plus - A Flutter plugin to get device Random Access Memory (RAM) size

system_info_plus A Flutter plugin to get device Random Access Memory (RAM) size.

Sebghatullah Yusuf 2 Aug 21, 2022
Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur

❤️ Sponsor get_it This is a simple Service Locator for Dart and Flutter projects with some additional goodies highly inspired by Splat. It can be used

Flutter Community 1k Jan 1, 2023
Flutter plugin (android) for sharing bytes and files Offline, (Based on the android Nearby Connections API)

nearby_connections An android flutter plugin for the Nearby Connections API Currently supports Bytes and Files. Transfer Data between multiple connect

Prerak Mann 63 Nov 21, 2022
Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation with a minimum password strength required.

password_strength_checker Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation wit

Dario Varriale 6 Aug 8, 2023
A Mobile application developed with Flutter and Dart to do math operations with binary numbers.

Math operations with Binary Numbers Readme PT About this Project Mobile application developed with Flutter and Dart to do math operations as sum, subt

Manoel Ribeiro 3 Nov 3, 2020
A shopper Flutter app that use BloC pattern and CRUD operations with different ways(memory/sqlite/http)

The project is maintained by a non-profit organisation, along with an amazing collections of Flutter samples. We're trying to make continuous commits

Flutter Samples 80 Nov 10, 2022
A flutter demo app to practice Map data structure and its common operations

Map Operations A flutter demo app to practice Map data structure and its common operations Developer Alexander Sosa (https://www.linkedin.com/in/alexa

Alexander Sosa 0 Jan 3, 2022
A Flutter application that demonstrate simple CRUD operations with Firebase cloud database.

Cricket Team A Flutter application that demonstrate simple CRUD operations with Firebase cloud database. Preview Home Empty Swipe Add Player Update Pl

Bhavik Makwana 45 Jun 19, 2021
A Flutter Task App with Parse (Back4app) as the backend demonstrating CRUD operations.

Siro's Task App Description A Flutter Task App with Parse (Back4app) as the backend demonstrating CRUD operations. Getx State Management Objective Thi

Jack Siro 4 Aug 27, 2022
Dart library for some Turkish language specific operations.

turkish This library provides these functions for Turkish language for Dart: Converting strings to lower, upper and title case. Regular and ignore cas

Ahmet A. Akın 39 Dec 27, 2022