boxx 0.0.3 boxx: ^0.0.3 copied to clipboard
Box is a lightweight and blazing fast key-value database written in pure Dart
Example of usage boxx
#
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);