writeString method

Future<void> writeString({
  1. required String key,
  2. required String value,
  3. bool isEncrypted = true,
})

write and read String data

Implementation

Future<void> writeString({required String key, required String value, bool isEncrypted = true}) async {
  final jsonData = json.encode(value);
  if (isEncrypted) {
    final encryptedData = _encrypter.encrypt(jsonData, iv: _iv).base64;
    await _secureStorage.write(key: key, value: encryptedData);
  } else {
    await _secureStorage.write(key: key, value: jsonData);
  }
}