buildImage method
Implementation
Widget buildImage(BuildContext context) {
bool urlValid = imageUrl.isEmpty == false;
if (urlValid == true) {
bool isNetworkUrl = imageUrl.startsWith(RegExp(r'https?:'));
urlValid = isNetworkUrl;
}
if (urlValid) {
// print("BaseTolerantNetworkImage imageUrl = $imageUrl");
/*
return Image(
image: NetworkImage(imageUrl),
// image: CachedNetworkImageProvider(imageUrl),
width: width,
height: height,
fit: BoxFit.fill,
gaplessPlayback: true, // //图片路径发生改变后,加载新图片过程中是否显示旧图
);
*/
return ExtendedImage.network(
imageUrl,
width: width,
height: height,
fit: fit,
cache: true,
gaplessPlayback: gaplessPlayback ?? true,
// clearMemoryCacheWhenDispose: true,
loadStateChanged: (ExtendedImageState state) {
if (loadStateChanged != null) {
loadStateChanged!(state, imageUrl);
}
return FadeWidget(
state: state,
duration: fadeInDuration ?? const Duration(milliseconds: 500),
progressIndicatorBuilder: progressIndicatorBuilder,
errorWidgetBuilder: errorWidget,
imageUrl: imageUrl,
child: ExtendedRawImage(
image: state.extendedImageInfo?.image,
width: width,
height: height,
fit: fit,
),
);
},
);
// return CachedNetworkImage(
// width: width,
// height: height,
// fit: fit,
// imageUrl: imageUrl,
// placeholder: placeholder,
// useOldImageOnUrlChange: true,
// errorWidget: (context, url, error) {
// if (this.errorWidget != null) {
// return this.errorWidget!(context, url, error);
// } else {
// return Container();
// }
// },
// placeholderFadeInDuration: placeholderFadeInDuration ?? Duration.zero,
// fadeOutDuration: fadeOutDuration ?? Duration.zero,
// fadeInDuration: fadeInDuration ?? Duration(milliseconds: 500),
// progressIndicatorBuilder: (context, url, progress) {
// if (this.progressIndicatorBuilder != null) {
// return this.progressIndicatorBuilder!(context, url, progress);
// } else {
// return Container(color: Color(0xFFF0F0F0));
// }
// },
// );
} else {
return Container(
width: width,
height: height,
color: const Color(0xFFF0F0F0),
);
}
}