Files
smooth-app/packages/smooth_app/lib/database/dao_instant_string.dart
Edouard Marquez a6569866d4 feat: Upgrade the Flutter version to 3.24 (#5613)
* Let's migrate the app to Flutter 3.24

* `openfoodfacts_flutter_lints` from the `main` branch

* A fix for `/// For the world view`
2024-09-26 16:48:01 +02:00

23 lines
703 B
Dart

import 'package:hive_flutter/hive_flutter.dart';
import 'package:smooth_app/database/abstract_dao.dart';
/// Where we store strings that need INSTANT access (= not lazy, no await).
class DaoInstantString extends AbstractDao {
DaoInstantString(super.localDatabase);
static const String _hiveBoxName = 'instantString';
@override
Future<void> init() async => Hive.openBox<String>(_hiveBoxName);
@override
void registerAdapter() {}
Box<String> _getBox() => Hive.box<String>(_hiveBoxName);
String? get(final String key) => _getBox().get(key);
Future<void> put(final String key, final String? value) async =>
value == null ? _getBox().delete(key) : _getBox().put(key, value);
}