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 {
  final path = await _storagePath;
  File file = File(_keyPath(path, key));

  if (await file.exists()) {
    String 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!);
    }

    try {
      return jsonDecode(contents);
    } catch (_) {
      return contents;
    }
  }
  return null;
}