What is LitBackupService?
LitBackupService is a Flutter package allowing you to create and restore backups using JSON files. This package does implement a very simple persistent (key-value pair) storage on local devices and should only be used as a secondary storage solution (such as for backuping other databases).
It does contain an abstract model class to provide a basic structure how backupable model classes should be defined. The JSON serialization should therefore be performed on each model class individually, as the models varies in structure.
This package is currently only supported on Android devices.
|Example HomeScreen||Example HomeScreen|
Required Permissions on Android
In order to read and write outside the app-specific directories, additional
permissions must be granted. These must be enabled on the
of your app located on
// Android devices prior to Android 11 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> // Optional on Android devices from Android 11 <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
Enabling the required permissions will be done using the
requestPermissions() method, which utilizes the
More recent releases of
are managing storage permissions on the file's purpose and have some restrictions. In order to access already existing backup files created using previous installations
on Android 10 and higher, the
MANAGE_EXTERNAL_STORAGE permissions must be granted.
The current installation won't be able to access them directly due to the altered
file privileges. This must be specified on the
flag. This practice is discouraged. Use the
methods to allow picking a specific file without the need of additional permissions.
Backups are stored on the device's Media directories by default. But custom file
paths are supported. The Media directories will include the Documents folder
/storage/emulated/0/Documents/ or the Download folder on
We recommend to use the Documents folder as backup location if possible for better security.
But for higher compatibility we recommend to use the
Download folder, due
to it being available on almost all Android devices.
This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
To get a better understanding for implementing the LitBackupService, we recommend
to take a look at the example app provided in the
example folder. Feel free to
experiment with the app.
LitBackupService uses the following Dart dependencies in order to implement certain features and functionality:
- permission_handler - License (Used to request storage access permissions)
- file_picker - License (Used to allow platform-specific file picking)
LitBackupService is made possible thanks to the Flutter Project.
Everything else in this repository including the source code is distributed under the
BSD 3-Clause license as specified in the
- A list of controller classes used to achieve certain functionality of this package.
- A list of data objects used to store constant data.
- A Flutter package to create and restore backups, whose content is formatted as a JSON files. [...]
- A list of model classes used to store and mutate data across this package.