listSync method
Retrieves a list of objects of type T
from the directory.
This method reads all the files in the directory and filters out the files that have a '.json' extension.
For each filtered file, it reads the contents, decrypts the JSON if encriptionKey is not blank, and converts it to an object of type T
.
The resulting objects are added to a list, which is returned at the end.
Returns a Iterable of objects of type T
.
Implementation
Iterable<T> listSync() {
return directory.listFilesSync.map((file) {
final encryptedJson = file.readAsStringSync();
final json = encriptionKey.isNotBlank ? encryptedJson.applyXorEncrypt(encriptionKey) : encryptedJson; // Decrypt the JSON if key is not blank
return fromJsonFunction(jsonDecode(json));
});
}