get method

  1. @override
Future get(
  1. String key
)
override

Get from local storage

Implementation

@override
/// Get from local storage
Future<dynamic> get(String key) async {
  try {
    dynamic contents;

    File file = File(keyPath(key));
    if (await file.exists()) {
      contents = await file.readAsString();
      if (mode == EncryptionMode.fernet && encryptionKey != null) {
        contents = fernet.decryptFernet(contents, encryptionKey!);
      } else if (mode == EncryptionMode.aes && encryptionKey != null) {
        contents = aes.decryptAES(contents, encryptionKey!);
      }
    }

    return contents;
  } on Exception catch (e) {
    debugPrint(e.toString());
    return null;
  }
}