BackupStorage class

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.

Constructors

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.
const

Properties

applicationName String
The application's name.
final
currentMediaPath Future<String>
Retrieves the currently selected Media directory on the local device's file system.
no setter
expectedBackupPath String
The expected file system path, where backups should be stored at.
no setter
fileExtension String
The backup file's extension. Defaults to EXTENSION_JSON.
final
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.
final
hashCode int
The hash code for this object.
no setterinherited
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+).
final
mediaLocation MediaLocation
The MediaLocation to store the backup in.
final
organizationName String
The application's creator.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
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.
final
useShortDirectoryNaming bool
Allows to only use the applicationName for directory naming. Ignores the provided organization name.
final

Methods

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 nonexistent method or property is accessed.
inherited
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.
inherited
writeBackup(BackupModel backup) Future<File>
Creates a backup file based on the provided BackupModel's content.

Operators

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