flush method
Flush all data to persistent storage (IndexedDB)
Implementation
Future<void> flush() async {
if (!_isInitialized) {
ObslyLogger.warn('Storage not initialized, cannot flush');
return;
}
try {
if (_useHive) {
// Force Hive to write to IndexedDB
ObslyLogger.debug('π Flushing data to IndexedDB...');
if (_eventsBox != null) {
await _eventsBox!.flush();
ObslyLogger.debug('β
Events box flushed to IndexedDB');
}
if (_internalStateBox != null) {
await _internalStateBox!.flush();
ObslyLogger.debug('β
Internal state box flushed to IndexedDB');
}
if (_performanceBox != null) {
await _performanceBox!.flush();
ObslyLogger.debug('β
Performance box flushed to IndexedDB');
}
ObslyLogger.log('πΎ All data flushed to IndexedDB successfully');
} else {
// SharedPreferences should auto-persist, but we can call commit if available
ObslyLogger.debug('πΎ SharedPreferences doesn\'t need manual flush');
}
} catch (e) {
ObslyLogger.error('Error flushing data: $e');
}
}