read method

Future<T?> read(
  1. String id
)

Reads the data with the specified ID.

Implementation

Future<T?> read(String id) async {
  final file = File('${directory.path}/$id.json');
  if (!await file.exists()) {
    return null;
  }
  final encryptedJson = await file.readAsString();
  final json = encriptionKey.isNotBlank ? encryptedJson.applyXorEncrypt(encriptionKey) : encryptedJson; // Decrypt the JSON if key is not blank
  final data = fromJsonFunction(jsonDecode(json));
  return data;
}