initialize method
Initialize all storage boxes
Implementation
Future<void> initialize({String? dir}) async {
if (_isInitialized) return;
dir ??= (await getApplicationDocumentsDirectory()).path;
Hive.init(dir);
try {
// Open all boxes
_userBox = await Hive.openBox(userBox);
_analyticsBox = await Hive.openBox(analyticsBox);
_engagementBox = await Hive.openBox(engagementBox);
_settingsBox = await Hive.openBox(settingsBox);
_isInitialized = true;
debugPrint('HiveStorageService initialized successfully');
} catch (e) {
debugPrint('Error initializing HiveStorageService: $e');
rethrow;
}
}