readSync method

T? readSync(
  1. K id
)

Reads the data with the specified ID.

Implementation

T? readSync(K id) {
  final file = File('${directory.path}/$id.json');
  if (!file.existsSync()) {
    return null;
  }
  final encryptedJson = file.readAsStringSync();
  final json = encriptionKey.isNotBlank ? encryptedJson.applyXorEncrypt(encriptionKey) : encryptedJson; // Decrypt the JSON if key is not blank
  return fromJsonFunction(jsonDecode(json));
}