BZImage constructor
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,
- bool isCircular = false,
- BorderRadius? borderRadius,
- 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,
);