前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >flutter 清除图片缓存

flutter 清除图片缓存

原创
作者头像
CatEatFish
修改2020-07-09 14:23:22
5.3K0
修改2020-07-09 14:23:22
举报
文章被收录于专栏:干活分享
代码语言:txt
复制
///实现Flutter框架的图像缓存的单例。
The singleton that implements the Flutter framework's image cache.

///该缓存由ImageProvider内部使用,通常不应该直接访问。
The cache is used internally by [ImageProvider](https://docs.flutter.io/flutter/painting/ImageProvider-class.html) and should generally not be accessed directly.

///图像缓存是在启动时由绘图绑定的绘图绑定创建的。createImageCache方法。
The image cache is created during startup by the  PaintingBinding's PaintingBinding.createImageCache  method.

介绍其中几个重要的方法

代码语言:txt
复制
1.获取ImageCache 缓存对象
 ImageCache get imageCache => PaintingBinding.instance.imageCache;
2.设置缓存图片的个数(根据情况自己设置,default = 1000)
  imageCache.maximumSize = 1000;
3.获取缓存图片个数
 int num = imageCache.currentSize;
4.设置缓存大小(根据情况自己设置,default = 50M)
 imageCache.maximumSizeBytes=50<<20;
5.获取图片缓存大小(单位是byte,需自行转换到 M)
int byte=imageCache.currentSizeBytes
6.清除图片缓存
 imageCache.clear();

自行查看flutter文档介绍

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档