persistent_user_dir_access_android 0.0.1 copy "persistent_user_dir_access_android: ^0.0.1" to clipboard
persistent_user_dir_access_android: ^0.0.1 copied to clipboard

PlatformAndroid

A package that leverages androids ACTION_OPEN_DOCUMENT_TREE and persists write permissions for a user chosen directory.

persistent_user_dir_access_android #

A lightweight, 0-dependency (except flutter) package to let android-users choose a directory for writing data between app restarts. All code is fully tested and documented.

Getting Started #

Using this package is very straight forward, let me demonstrate:

Future<void> saveText(String text) async {
  // Requiring a class instance allows for easy debugging.
  final userDirs = userDirs = const PersistentUserDirAccessAndroid();
  
  // This shows the OS dir-picker to the users.
  final String selectedDirUri = await userDirs.requestDirectoryUri();
  
  // You can always save a dir-URI for later use, even after app restarts.
  this.selectedUri = selectedDirUri;
  
  // Pass your URI to the `writeFile` method to create a new file:
  await userDirs.writeFile(
    selectedDirUri,
    'test.txt', // filename passed to android. The OS automatically avoids overriding files
    'text/plain', // specify mime-type
    utf8.encode(text), // Pass binary data
  );
}

For more usage info, check out the example directory.

Contributing #

PRs and issues are welcome. Check out CONTRIBUTING.md for more info.

0
likes
150
points
27
downloads

Publisher

verified publisherderdilla.com

Weekly Downloads

A package that leverages androids ACTION_OPEN_DOCUMENT_TREE and persists write permissions for a user chosen directory.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on persistent_user_dir_access_android