import 'dart:io'; import 'package:hive/hive.dart'; import 'package:hive_flutter/adapters.dart'; import 'package:paperless_mobile/core/database/hive/hive_config.dart'; import 'package:paperless_mobile/core/database/tables/global_settings.dart'; import 'package:paperless_mobile/core/database/tables/local_user_account.dart'; import 'package:paperless_mobile/core/database/tables/local_user_app_state.dart'; Future initHive(Directory directory, String defaultLocale) async { Hive.init(directory.path); registerHiveAdapters(); await Hive.openBox(HiveBoxes.localUserAccount); await Hive.openBox(HiveBoxes.localUserAppState); await Hive.openBox(HiveBoxes.hintStateBox); await Hive.openBox(HiveBoxes.hosts); final globalSettingsBox = await Hive.openBox(HiveBoxes.globalSettings); if (!globalSettingsBox.hasValue) { await globalSettingsBox.setValue( GlobalSettings(preferredLocaleSubtag: defaultLocale), ); } }