简体   繁体   English

如何更新 Flutter 中的现有文件(Path_Provider)

[英]How to update the Existing File (Path_Provider) in Flutter

I have a question about path_provider package, i'm fetching the api data and once i received the data i cache the json data in File .我对path_provider package 有疑问,我正在获取 api 数据,一旦我收到数据,我将json数据缓存在File中。 How can i update the existing file, Because whenever i got any changes or updates in api data then it doesn't make any update or refresh on cache file data.我如何更新现有文件,因为每当我对 api 数据进行任何更改或更新时,它就不会对缓存文件数据进行任何更新或刷新。 Is there any articles or documents or videos to show how to update the existing file?是否有任何文章或文档或视频来展示如何更新现有文件?

You can just add你可以添加

File(path).deleteSync(recursive: true);

to delete the existing file then recreate it as it's a new.删除现有文件,然后重新创建它,因为它是一个新文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM