Last active
June 6, 2021 02:10
-
-
Save VB10/2ed6658eecf5df32aeba66cd896bc088 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Future<ItemModel?> takeItemWithCache(int? id) async { | |
if (_directory == null) { | |
final appDirectory = await createDirectory(); | |
_directory ??= await Directory('${appDirectory.path}/$_localPath').create(); | |
} | |
final items = await _directory!.list().toSet(); | |
final _item = items.firstWhereOrNull((element) => element.path.contains('$id')); | |
if (_item != null) { | |
if (await _item.exists()) { | |
final file = File(_item.path); | |
final jsonBody = json.decode(await file.readAsString()); | |
final feedItem = ItemModel.fromJson(jsonBody); | |
feedItem.itemValues = encrypData.decryptFile(feedItem.itemValues ?? ''); | |
return feedItem; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment