mirror of
https://github.com/openfoodfacts/smooth-app.git
synced 2025-08-06 18:25:11 +08:00

* Let's migrate the app to Flutter 3.24 * `openfoodfacts_flutter_lints` from the `main` branch * A fix for `/// For the world view`
23 lines
607 B
Dart
23 lines
607 B
Dart
import 'package:hive_flutter/hive_flutter.dart';
|
|
import 'package:smooth_app/database/abstract_dao.dart';
|
|
|
|
/// Where we store ints.
|
|
class DaoInt extends AbstractDao {
|
|
DaoInt(super.localDatabase);
|
|
|
|
static const String _hiveBoxName = 'int';
|
|
|
|
@override
|
|
Future<void> init() async => Hive.openBox<int>(_hiveBoxName);
|
|
|
|
@override
|
|
void registerAdapter() {}
|
|
|
|
Box<int> _getBox() => Hive.box<int>(_hiveBoxName);
|
|
|
|
int? get(final String key) => _getBox().get(key);
|
|
|
|
Future<void> put(final String key, final int? value) async =>
|
|
value == null ? _getBox().delete(key) : _getBox().put(key, value);
|
|
}
|