ImageUtil class

Constructors

ImageUtil()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

base64CacheSize → int
获取已缓存解码字节的条数,不包含仅有尺寸或无效标记的条目。
no setter

Static Methods

clearBase64Cache() → void
清空 base64 数据、尺寸和无效输入缓存。
clearImageCache() → void
账号生命周期结束时释放全部图片静态缓存。
detectImageFormat(String filePath) → Future<String?>
ensureImageExtension(String filePath, String? mimeType) → String
根据文件内容识别出的格式,返回可直接用于保存的图片路径。
getAvatarWidget(String? imagePath, {String defaultImagePath = 'avatar_default_single.png', double? width, double? height, BoxFit fit = BoxFit.cover}) → Widget
构建头像图片。头像地址为空或网络加载失败时展示指定的默认头像。
getBase64NaturalSize(String base64String) → Size?
使用 image_size_getter 获取天然像素尺寸,未进行全图像素解码。
getDecodedBase64(String base64String) → Uint8List?
从缓存中获取已解码的数据;超预算数据仍返回,但不长期保留。
getFileNaturalSize(String filePath) → Size?
获取本地文件图片的天然像素尺寸(使用 image_size_getter,命中缓存则直接返回) filePath 支持普通路径或以 file:// 开头的路径
getImageWidget(String imagePath, {double? width, double? height, bool inRongCloud = true, Color? color, BoxFit fit = BoxFit.cover, String? thumbnailBase64String, bool notInAssets = false, Widget? errorWidget, Widget? placeholderWidget}) → Widget
获取图片 Widget,可以自动判断图片路径类型
isValidBase64Image(String base64String) → bool
判断 base64 字符串是否是可直接解码渲染的图片数据。
limitCacheSize(int maxSize) → void
限制解码字节条数,按 LRU 同步淘汰关联尺寸及无效标记。
removeFromCache(String base64String) → void
移除同一 base64 的数据、尺寸和无效标记。