Box is a lightweight and blazing fast key-value database written in pure Dart.
Features
Box is a lightweight storage solution with optional encryption built in. Its simple, powerful, & intuitive API get's you up and running in no time.
Getting started
Without Encryption
late Box box;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await initBox();
}
initBox() async {
if (kIsWeb) {
box = Box(path: '');
} else {
final directory = await getApplicationDocumentsDirectory();
box = Box(path: directory.path);
}
}
With Encryption
late Box box;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await initBox();
}
initBox() async {
if (kIsWeb) {
box = Box(path: '',encryptionKey: 'xxxxxxxx',mode: EncryptionMode.aes);
} else {
final directory = await getApplicationDocumentsDirectory();
box = Box(path: directory.path,encryptionKey: 'xxxxxxxx',mode: EncryptionMode.aes);
}
}
Usage
Delete
box.delete('UserData');
Get
final contents = await box.get('UserData');
Put
box.put('UserData', response.body);
Additional information
Box supports 2 Encryption Algorithms 1) AES Algorithms 2) Fernet Algorithms