如何在Flutter上以编程方式清除应用程序缓存 [英] How to clear app cache programmatically on Flutter

查看:35
本文介绍了如何在Flutter上以编程方式清除应用程序缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为我一直在使用Flutter开发应用程序.我发现应用程序的体积很大,而且它占用大量空间作为应用程序数据和应用程序缓存.有什么方法可以通过编程方式清除应用程序缓存吗?

As I have been developing app using Flutter. I came to find that app is heavy in size plus it is using a lot of space as app data and app cache. Is there any way to clear app cache programmatically?

在发布模式下,我的应用程序大小约为7mb,应用程序数据约为11mb.我的应用程序在应用程序内打开了一个站点,并且还流播了在线广播,因此其应用程序数据还在不断增加

my app's size in release mode is about 7mb and app data is about 11mb. My app opens one site within app and it also streams online radio so it's app data goes on increasing

推荐答案

您可以获取temp文件夹,然后删除其中的文件.

You can get the temp folder, and delete files in it.

var appDir = (await getTemporaryDirectory()).path;
new Directory(appDir).delete(recursive: true);

这篇关于如何在Flutter上以编程方式清除应用程序缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆