get method

Future get(
  1. String key
)

Get from local storage

Implementation

Future<dynamic> get(String key) async {
  try {
    dynamic contents = '';
    key = '${sanitizeFilename(key)}.boxx';
    if (!kIsWeb) {
      File file = File('$path/$key');
      if (await file.exists()) {
        if (encryptionKey == null) {
          contents = await file.readAsString();
        } else {
          contents = await file.readAsString();
          if (mode == EncryptionMode.fernet) {
            contents = fernet.decryptFernet(contents, encryptionKey!);
          } else {
            contents = aes.decryptAES(contents, encryptionKey!);
          }
        }
      }
    }
    return contents;
  } on Exception catch (e) {
    debugPrint(e.toString());
    return '';
  }
}