import 'package:hive_flutter/hive_flutter.dart'; import 'package:smooth_app/database/abstract_dao.dart'; /// Where we store strings. /// /// Typical use case: large strings used for onboarding. /// That's why we use lazy boxes, and not boxes, and not sharedpreferences: /// we're talking about large data (several 10Kb) that we almost never need, /// and that should not make the app boot slower. class DaoString extends AbstractDao { DaoString(super.localDatabase); static const String _hiveBoxName = 'string'; @override Future init() async => Hive.openLazyBox(_hiveBoxName); @override void registerAdapter() {} LazyBox _getBox() => Hive.lazyBox(_hiveBoxName); Future get(final String key) async => _getBox().get(key); Future put(final String key, final String? value) async => value == null ? _getBox().delete(key) : _getBox().put(key, value); }