
正文
flutter置顶,flutter常见问题
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
flutter图片内存优化
按照给定尺寸进行图片的解码,而不是解码整个图片的尺寸,用来减少内存的占用。
官方文档:
官方说明:
Instructs Flutter to decode the image at the specified dimensions instead of at its native size.
This allows finer control of the size of the image in ImageCache and is generally used to reduce the memory footprint of ImageCache .
The decoded image may still be displayed at sizes other than the cached size provided here.
使用:
三方库: cached_network_image 限2.5.0之后版本才可用
设定最大的缓存宽度和高度 this.maxWidthDiskCache 、 this.maxHeightDiskCache
使用:
从相册选取图片,展示时使用指定尺寸宽高进行处理。
使用三方库:
使用自定义 provider 来指定所需图片的宽高:
AssetEntityImageProvider 传入宽高和图片原图 AssetEntity 数据。
provider 中 key.entity.thumbDataWithSize 方法:
进入 entity 中 thumbDataWithSize 方法:
进入 _getThumbDataWithId 方法中,
进入getThumb:
调用iOS原生的获取图片方法,
进入 getThumbWithId 方法,
原生实现获取置顶宽高缩略图方法实现:
使用 iOS 原生类 PHImageManager 的
来获取缩略图。







