BackupStorage class Null safety

A controller class handling read and write operations of backups to local storage.

Backups are preferably stored on the device's Media directories (MediaLocation). The organizationName will be a directory in the Media directory, whereas the applicationName will be a subdirectory (inside the organizationName directory). This will help the user to organize different backups of different applications.

A organizationName of MyOrganization, a applicationName of MyApp and a fileName of examplebackup on the Documents media directory would compound a complete path of /storage/emulated/0/Documents/MyOrganization/MyApp/examplebackup.json.


BackupStorage({required String organizationName, required String applicationName, required String fileName, MediaLocation mediaLocation = MediaLocation.DOWNLOAD_LOCATION_ANDROID, bool useManageExternalStoragePermission = false, String fileExtension = EXTENSION_JSON, required String installationID, bool useShortDirectoryNaming = false})
Creates a BackupStorage.


applicationName String
The application's name.
currentMediaPath Future<String>
Retrieves the currently selected Media directory on the local device's file system.
expectedBackupPath String
The expected file system path, where backups should be stored at.
fileExtension String
The backup file's extension. Defaults to EXTENSION_JSON.
fileName String
The file's name. The file extention will not be required, because all backup files ẁill have the json extension exclusively by default.
hashCode int
The hash code for this object.
installationID String
The installationID is required in order to allow varying file names when using the same app on different installations or on the different devices. One installationID must not match the previous installation's id in order to preserve the scoped file privilege enforced on Android 10 or higher (API 29+).
mediaLocation MediaLocation
The MediaLocation to store the backup in.
organizationName String
The application's creator.
runtimeType Type
A representation of the runtime type of the object.
useManageExternalStoragePermission bool
States whether to use the Android's Manage External Storage permission. Requesting this permission will enable full access to all external storage on Android 10 (API level 29) and higher. This will enable the app access to all folders on the devices and therefore will allow backups to be restored without the user having to provide a specific backup document.
useShortDirectoryNaming bool
Allows to only use the applicationName for directory naming. Ignores the provided organization name.


deleteBackup() Future<void>
Deletes the existing backup file.
hasPermissions() Future<bool>
Evaluates whether all required permissions have been granted.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
pickBackupFile({required BackupModel decode(String)}) Future<BackupModel?>
Shows the platform's native file explorer in order to pick a specific backup file.
readBackup({required BackupModel decode(String)}) Future<BackupModel?>
Reads the backup from the selected location.
requestPermissions() Future<void>
Request all required permissions to access the existing backup files stored on the Media locations.
toString() String
A string representation of this object.
writeBackup(BackupModel backup) Future<File>
Creates a backup file based on the provided BackupModel's content.


operator ==(Object other) bool
The equality operator.