BZImage constructor

BZImage({
  1. Key? key,
  2. required String? imageUrl,
  3. PlaceholderWidgetBuilder? placeholder,
  4. LoadingErrorWidgetBuilder? errorWidget,
  5. double? width,
  6. double? height,
  7. BoxFit fit = BoxFit.cover,
  8. Alignment alignment = Alignment.center,
  9. ImageRepeat repeat = ImageRepeat.noRepeat,
  10. Map<String, String>? httpHeaders,
  11. BaseCacheManager? cacheManager,
  12. String? cacheKey,
  13. Duration fadeInDuration = const Duration(milliseconds: 300),
  14. Curve fadeInCurve = Curves.easeIn,
  15. Duration fadeOutDuration = const Duration(milliseconds: 1000),
  16. Curve fadeOutCurve = Curves.easeOut,
  17. bool useOldImageOnUrlChange = false,
  18. bool matchTextDirection = false,
  19. bool isCircular = false,
  20. BorderRadius? borderRadius,
  21. BoxBorder? border,
})

Implementation

BZImage({
  Key? key,
  required String? imageUrl,
  PlaceholderWidgetBuilder? placeholder,
  LoadingErrorWidgetBuilder? errorWidget,
  double? width,
  double? height,
  BoxFit fit = BoxFit.cover,
  Alignment alignment = Alignment.center,
  ImageRepeat repeat = ImageRepeat.noRepeat,
  Map<String, String>? httpHeaders,
  BaseCacheManager? cacheManager,
  String? cacheKey,
  Duration fadeInDuration = const Duration(milliseconds: 300),
  Curve fadeInCurve = Curves.easeIn,
  Duration fadeOutDuration = const Duration(milliseconds: 1000),
  Curve fadeOutCurve = Curves.easeOut,
  bool useOldImageOnUrlChange = false,
  bool matchTextDirection = false,
  this.isCircular = false,
  this.borderRadius,
  this.border,
}) : super(
        key: key,
        imageUrl: BZObjectUtil.isNotEmpty(imageUrl) ? imageUrl! : 'base64://',
        placeholder: (
          BuildContext context,
          String url,
        ) {
          Widget? widget = placeholder?.call(context, url);
          if (widget == null &&
              Get.isRegistered<BZImageConfig>() &&
              Get.find<BZImageConfig>().placeholder != null) {
            widget = SizedBox(
              width: width,
              height: height,
              child: Get.find<BZImageConfig>().placeholder,
            );
          }
          return widget ?? SizedBox(width: width, height: height);
        },
        errorWidget: (
          BuildContext context,
          String url,
          dynamic error,
        ) {
          Widget? widget = errorWidget?.call(context, url, error);
          if (widget == null &&
              Get.isRegistered<BZImageConfig>() &&
              Get.find<BZImageConfig>().errorWidget != null) {
            widget = SizedBox(
              width: width,
              height: height,
              child: Get.find<BZImageConfig>().errorWidget,
            );
          }
          return widget ?? SizedBox(width: width, height: height);
        },
        width: width,
        height: height,
        fit: fit,
        alignment: alignment,
        repeat: repeat,
        httpHeaders: httpHeaders,
        cacheManager: cacheManager,
        cacheKey: cacheKey,
        fadeInDuration: fadeInDuration,
        fadeInCurve: fadeInCurve,
        fadeOutDuration: fadeOutDuration,
        fadeOutCurve: fadeOutCurve,
        useOldImageOnUrlChange: useOldImageOnUrlChange,
        matchTextDirection: matchTextDirection,
      );