ImageView constructor

ImageView(
  1. String imageUri, {
  2. Key? key,
  3. double? width,
  4. double? height,
  5. double? size,
  6. int? cacheWidth,
  7. int? cacheHeight,
  8. int? cacheSize,
  9. BoxFit? fit = BoxFit.cover,
  10. Color? color,
  11. EdgeInsets? padding,
  12. EdgeInsets? margin,
  13. String? darkImagePath,
  14. bool autoDarkMode = false,
  15. bool autoApplyKey = true,
  16. BoxDecoration? decoration,
  17. BoxDecoration? foregroundDecoration,
  18. Clip? clipBehavior = Clip.hardEdge,
  19. double? aspectRatio,
  20. BorderRadius? borderRadius,
  21. BoxShape? shape,
  22. BlendMode? colorBlendMode,
  23. Widget? errorWidget,
  24. Widget? placeholder,
  25. double? scale,
})

根据图片uri自动判断是使用本地加载还是远程加载

Implementation

ImageView(
  String imageUri, {
  super.key,
  this.width,
  this.height,
  this.size,
  this.cacheWidth,
  this.cacheHeight,
  this.cacheSize,
  this.fit = BoxFit.cover,
  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',
      );