get method
Get from local storage
Implementation
@override
/// Get from local storage
Future<dynamic> get(String key) async {
try {
final db = await _initDB();
final transaction = db.transaction(storeName, 'readonly');
final store = transaction.objectStore(storeName);
dynamic data = await store.getObject(key);
if (data != null) {
if (mode == EncryptionMode.fernet && encryptionKey != null) {
data = fernet.decryptFernet(data, encryptionKey!);
} else if (mode == EncryptionMode.aes && encryptionKey != null) {
data = aes.decryptAES(data, encryptionKey!);
}
}
await transaction.completed;
db.close();
return data;
} catch (e) {
debugPrint(e.toString());
return null;
}
}