189 8069 5689

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 的

来获取缩略图。


当前文章:flutter置顶,flutter常见问题
文章起源:http://cdxtjz.cn/article/dssjdce.html

其他资讯