ImageLoader class

图片工具类

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

config ImageLoaderConfig
获取当前配置
no setter
imgCache Map<String, Uint8List>
getter/setter pair

Static Methods

asset(String name, {Key? key, ImageFrameBuilder? frameBuilder, ImageErrorWidgetBuilder? errorBuilder, String? semanticLabel, bool excludeFromSemantics = false, Color? color, double? scale, double? width, double? height, Animation<double>? opacity, BoxFit? fit = BoxFit.cover, BlendMode? colorBlendMode, ImageRepeat repeat = ImageRepeat.noRepeat, AlignmentGeometry alignment = Alignment.center, Rect? centerSlice, bool matchTextDirection = false, bool isAntiAlias = false, bool gaplessPlayback = false, int? cacheWidth, int? cacheHeight, FilterQuality filterQuality = FilterQuality.medium, bool? isRe, bool circular = false, double? radius, BorderRadius? borderRadius, BoxBorder? border}) Widget
加载本地资源图片 name 资源名称 isRe 是否使用特殊路径,如果为null则使用全局配置 circular 是否设置为圆形 radius 圆角半径 borderRadius 自定义圆角
cachedNetwork(String? imageUrl, {double? width, double? height, String? placeholder, ImageErrorWidgetBuilder? errorBuilder, Alignment alignment = Alignment.center, BoxFit? fit = BoxFit.cover, BoxFit? placeholderFit = BoxFit.cover, Duration? fadeOutDuration, Duration? placeholderFadeInDuration, Duration? fadeInDuration, bool? useOldImageOnUrlChange, bool matchTextDirection = false, bool circular = false, double? radius, BorderRadius? borderRadius, BoxBorder? border}) Widget
加载一张网络图片并使用缓存 imageUrl 网络图片的地址 width 图片视图宽 height 图片视图高 placeholder 加载占位图,如果为空则使用全局配置的默认占位图 alignment 对齐方式,默认 Alignment.center fit 网络图片的裁剪方式 placeholderFit 占位图片的裁剪方式 fadeOutDuration 淡出动画时长 placeholderFadeInDuration 占位图淡入动画时长 fadeInDuration 图片淡入动画时长 useOldImageOnUrlChange 是否在URL改变时使用旧图片 circular 是否设置为圆形 radius 圆角半径 borderRadius 自定义圆角
file(String localPath, {double? size, double? width, double? height, Key? key, ImageFrameBuilder? frameBuilder, ImageErrorWidgetBuilder? errorBuilder, String? semanticLabel, bool excludeFromSemantics = false, Color? color, double? scale, Animation<double>? opacity, BoxFit? fit = BoxFit.cover, BlendMode? colorBlendMode, ImageRepeat repeat = ImageRepeat.noRepeat, AlignmentGeometry alignment = Alignment.center, Rect? centerSlice, bool matchTextDirection = false, bool isAntiAlias = false, bool gaplessPlayback = false, int? cacheWidth, int? cacheHeight, FilterQuality filterQuality = FilterQuality.medium, String? placeholder, bool circular = false, double? radius, BorderRadius? borderRadius, BoxBorder? border}) Widget
加载文件图片
getUint8List(String name) Uint8List?
imageProvider(String name, {bool? isRe}) ImageProvider<Object>
获取图片提供者 name 资源名称 isRe 是否使用特殊路径,如果为null则使用全局配置
local(String name, {double? size, double? width, double? height, BoxFit? fit = BoxFit.cover, bool? isRe, bool matchTextDirection = false, bool circular = false, double? radius, BorderRadius? borderRadius, BoxBorder? border}) Widget
便捷方法:加载本地图片(使用全局配置) circular 是否设置为圆形 radius 圆角半径 borderRadius 自定义圆角
memory(Uint8List bytes, {double? size, double? width, double? height, int? cacheWidth, int? cacheHeight, Key? key, ImageFrameBuilder? frameBuilder, ImageErrorWidgetBuilder? errorBuilder, String? semanticLabel, bool excludeFromSemantics = false, Color? color, double? scale, Animation<double>? opacity, BoxFit? fit = BoxFit.cover, BlendMode? colorBlendMode, ImageRepeat repeat = ImageRepeat.noRepeat, AlignmentGeometry alignment = Alignment.center, Rect? centerSlice, bool matchTextDirection = false, bool isAntiAlias = false, bool gaplessPlayback = false, FilterQuality filterQuality = FilterQuality.medium, bool circular = false, double? radius, BorderRadius? borderRadius, BoxBorder? border}) Widget
从Uint8List数据加载图片 bytes 图片的字节数据 width 图片视图宽 height 图片视图高 fit 图片填充方式 circular 是否设置为圆形 radius 圆角半径 borderRadius 自定义圆角
network(String? imageUrl, {double? size, double? width, double? height, String? placeholder, BoxFit? fit = BoxFit.cover, Alignment alignment = Alignment.center, bool circular = false, double? radius, BorderRadius? borderRadius, BoxBorder? border}) Widget
便捷方法:加载网络图片(使用全局配置) circular 是否设置为圆形 radius 圆角半径 borderRadius 自定义圆角
preloadNetworkImage(String? imageUrl, BuildContext context, ImageStreamListener? listener) → void
预加载图片
setConfig(ImageLoaderConfig config) → void
设置全局配置