CustomImage.asset constructor

CustomImage.asset(
  1. String assetName, {
  2. Key? key,
  3. Size? size,
  4. BoxFit? fit,
  5. double? width,
  6. double? height,
  7. BoxShape? shape,
  8. double? scaleByWidth,
  9. double? scaleByHeight,
  10. Color? color,
  11. GestureTapCallback? onTap,
  12. Curve? curve,
  13. EdgeInsetsGeometry? margin,
  14. EdgeInsetsGeometry? padding,
  15. Animation<double>? opacity,
  16. String? package,
  17. Rect? centerSlice,
  18. GestureLongPressCallback? onLongPress,
  19. ImageFrameBuilder? frameBuilder,
  20. ImageErrorWidgetBuilder? errorBuilder,
  21. BorderRadius? borderRadius,
  22. String? semanticLabel,
  23. AssetBundle? bundle,
  24. BlendMode? colorBlendMode,
  25. Color? backgroundColor,
  26. Duration? animationDuration,
  27. bool isAntiAlias = false,
  28. bool gaplessPlayback = false,
  29. bool matchTextDirection = false,
  30. bool excludeFromSemantics = false,
  31. AlignmentGeometry alignment = Alignment.center,
  32. ImageRepeat repeat = ImageRepeat.noRepeat,
  33. FilterQuality filterQuality = FilterQuality.medium,
})

Implementation

CustomImage.asset(
  String assetName, {
  super.key,
  Size? size,
  BoxFit? fit,
  double? width,
  double? height,
  BoxShape? shape,
  double? scaleByWidth, // 固定宽度等比缩放
  double? scaleByHeight, // 固定高度等比缩放
  this.color,
  this.onTap,
  this.curve,
  this.margin,
  this.padding,
  this.opacity,
  String? package,
  this.centerSlice,
  this.onLongPress,
  this.frameBuilder,
  this.errorBuilder,
  this.borderRadius,
  this.semanticLabel,
  AssetBundle? bundle,
  this.colorBlendMode,
  this.backgroundColor,
  this.animationDuration,
  this.isAntiAlias = false,
  this.gaplessPlayback = false,
  this.matchTextDirection = false,
  this.excludeFromSemantics = false,
  this.alignment = Alignment.center,
  this.repeat = ImageRepeat.noRepeat,
  this.filterQuality = FilterQuality.medium,
})  : _image = AssetImage(assetName, bundle: bundle, package: package),
      loadingBuilder = null,
      width = _computeScaleWidth(
          scaleByWidth, scaleByHeight, width, height, size),
      height = _computeScaleHeight(
          scaleByWidth, scaleByHeight, width, height, size),
      fit = _handleFit(fit, scaleByWidth, scaleByHeight),
      shape = _handleShape(shape, scaleByWidth, scaleByHeight);