saf_util 0.1.0 saf_util: ^0.1.0 copied to clipboard
Util functions for SAF (Storage Access Framework).
saf_util #
Util functions for SAF (Storage Access Framework). Note that this package doesn't provide any read / write functions (go to saf_stream for that).
Usage #
class SafUtil {
/// Shows a folder picker dialog and returns the selected folder URI.
///
/// [initialUri] is the initial URI to show in the dialog.
/// [writePermission] is true if the folder should have write permission.
/// [persistablePermission] is true if the permission should be persistable.
Future<String?> openDirectory(
{String? initialUri,
bool? writePermission,
bool? persistablePermission});
/// Lists the contents of the specified directory URI.
///
/// [uri] is the URI of the directory.
Future<List<SafDocumentFile>> list(String uri);
/// Gets a [SafDocumentFile] object from the specified URI.
///
/// [uri] is the URI of the file or directory.
/// [isDir] is true if the URI is a directory.
Future<SafDocumentFile?> documentFileFromUri(String uri, bool isDir);
/// Checks if the specified file or directory exists.
///
/// [uri] is the URI of the file or directory.
/// [isDir] is true if the URI is a directory.
Future<bool> exists(String uri, bool isDir);
/// Deletes the specified file or directory.
///
/// [uri] is the URI of the file or directory.
/// [isDir] is true if the URI is a directory.
Future<void> delete(String uri, bool isDir);
/// Creates a directory and all its parent directories.
///
/// [uri] is the URI of the directory to create.
/// [names] is a list of directory names to create.
Future<SafDocumentFile> mkdirp(String uri, List<String> names);
/// Gets the child file or directory with the specified name.
///
/// [uri] is the URI of the parent directory.
/// [names] is a list of directory names to traverse.
Future<SafDocumentFile?> child(String uri, List<String> names);
/// Renames the specified file or directory.
///
/// [uri] is the URI of the file or directory.
/// [isDir] is true if the URI is a directory.
/// [newName] is the new name of the file or directory.
Future<SafDocumentFile> rename(String uri, bool isDir, String newName);
/// Moves the specified file or directory to a new parent directory.
///
/// [uri] is the URI of the file or directory.
/// [parentUri] is the URI of the current parent directory.
/// [newParentUri] is the URI of the new parent directory.
Future<SafDocumentFile> moveTo(
String uri, bool isDir, String parentUri, String newParentUri);
/// Copies the specified file or directory to a new parent directory.
///
/// [uri] is the URI of the file or directory.
/// [newParentUri] is the URI of the new parent directory.
Future<SafDocumentFile> copyTo(String uri, bool isDir, String newParentUri);
}