ImageView.icon constructor
ImageView.icon(
- String imageUri, {
- Key? key,
- double? width,
- double? height,
- double? size,
- int? cacheWidth,
- int? cacheHeight,
- int? cacheSize,
- BoxFit? fit = BoxFit.contain,
- Color? color,
- EdgeInsets? padding,
- EdgeInsets? margin,
- String? darkImagePath,
- bool autoDarkMode = false,
- bool autoApplyKey = true,
- BoxDecoration? decoration,
- BoxDecoration? foregroundDecoration,
- Clip? clipBehavior = Clip.hardEdge,
- double? aspectRatio,
- BorderRadius? borderRadius,
- BoxShape? shape,
- BlendMode? colorBlendMode,
- Widget? errorWidget,
- Widget? placeholder,
- double? scale,
跟默认构造器的区别是icon构造器默认是BoxFit.contain
Implementation
ImageView.icon(
String imageUri, {
super.key,
this.width,
this.height,
this.size,
this.cacheWidth,
this.cacheHeight,
this.cacheSize,
this.fit = BoxFit.contain,
this.color,
this.padding,
this.margin,
this.darkImagePath,
this.autoDarkMode = false,
this.autoApplyKey = true,
this.decoration,
this.foregroundDecoration,
this.clipBehavior = Clip.hardEdge,
this.aspectRatio,
this.borderRadius,
this.shape,
this.colorBlendMode,
this.errorWidget,
this.placeholder,
this.scale,
}) : imagePath = imageUri.isUrl ? null : imageUri,
imageUrl = imageUri.isUrl ? imageUri : null,
assert(
(darkImagePath != null && autoDarkMode == false) ||
darkImagePath == null,
'不能同时设置darkImagePath和autoDarkMode',
);