getString method
Retrieve a String value
Returns null if key doesn't exist Throws SecureStorageException if decryption fails
Implementation
Future<String?> getString(String key) async {
_checkInit();
try {
// Check cache first
if (_cache.containsKey(key)) {
final encrypted = _cache[key]!;
return _decrypt(encrypted);
}
return await _withRetry(() async {
final encrypted = await _secureStorage.read(key: key);
if (encrypted == null) return null;
_updateCache(key, encrypted);
return _decrypt(encrypted);
});
} catch (e) {
throw SecureStorageException(
'Failed to retrieve string for key: $key',
e,
);
}
}