writeJson method

Future<void> writeJson({
  1. required String key,
  2. required Map<String, dynamic> jsonMap,
  3. bool isEncrypted = true,
})

write and read JSON data

Implementation

Future<void> writeJson({required String key, required Map<String, dynamic> jsonMap, bool isEncrypted = true}) async {
  final jsonData = json.encode(jsonMap);
  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);
  }
}