setString method

Future<void> setString(
  1. String key,
  2. String value
)

Store a String value

Throws SecureStorageException if operation fails

Implementation

Future<void> setString(String key, String value) async {
  _checkInit();
  _validateKey(key);
  try {
    await _withRetry(() async {
      final encrypted = _encrypt(value);
      await _secureStorage.write(key: key, value: encrypted);
      _updateCache(key, encrypted);
    });
  } catch (e) {
    throw SecureStorageException('Failed to store string for key: $key', e);
  }
}