requestAllKeys method

Future<void> requestAllKeys()

Requests all legacy and async keys and post an event with the result.

Implementation

Future<void> requestAllKeys() async {
  final EncryptedSharedPreferences legacyPrefs =
      EncryptedSharedPreferences.getInstance();
  Set<String> legacyKeys = {};
  Set<String> asyncKeys = {};
  try {
    asyncKeys = await EncryptedSharedPreferencesAsync.getInstance().getKeys();
  } catch (e) {
    print('Async api not initialized');
  }

  try {
    legacyKeys = legacyPrefs.getKeys();
  } catch (e) {
    print('Legacy api not initialized');
  }

  _postEvent('${_eventPrefix}all_keys', <String, List<String>>{
    'asyncKeys': asyncKeys.toList(),
    'legacyKeys': legacyKeys.toList(),
  });
}