getAllInternalStateKeys method

Future<List<String>> getAllInternalStateKeys()

Get all internal state keys

Implementation

Future<List<String>> getAllInternalStateKeys() async {
  if (!_isInitialized) {
    await initialize();
  }

  try {
    if (_useHive && _internalStateBox != null) {
      final keys = _internalStateBox!.keys.cast<String>().toList();
      ObslyLogger.debug('Retrieved ${keys.length} internal state keys from Hive');
      return keys;
    } else if (_prefs != null) {
      final prefKeys = _prefs!
          .getKeys()
          .where((key) => key.startsWith('obsly_state_'))
          .map((key) => key.substring('obsly_state_'.length))
          .toList();
      ObslyLogger.debug('Retrieved ${prefKeys.length} internal state keys from SharedPreferences');
      return prefKeys;
    }
  } catch (e) {
    ObslyLogger.error('Error getting all internal state keys: $e');
  }

  return [];
}