How can i hide the CachedNetworkImage if there is an image issue.
Hi, Your package is working great. I just have a one question. I'm showing the big images in the list view. I need help and suggestions. Basically there are some urls in the listview which have no images like they throw 404 error. And I'm handling these errors and showing the default images at the place of 404 images.
But now I want to hide the whole CachedNetworkImage on error instead of showing a place holder image. Here is my code
CachedNetworkImage( width: double.maxFinite, fit: BoxFit.fill, height: 200, imageUrl: widget.model?.getPictureUrl ?? "", progressIndicatorBuilder: (context, url, downloadProgress) => Container( color: Colors.white, child: Center( child: Padding( padding: const EdgeInsets.all(4.0), child: CircularProgressIndicator(value: downloadProgress.progress), ))), errorWidget: (context, url, error) => SizedBox.shrink())
Currently is showing an empty box but the box height is 200 so its looks bad. So my main concern is i need to hide full CachedNetworkImage in the listview with best approach. Can anyone please guide and help me. Thanks
I suggest not passing size to CachedNetworkImage, but to imageBuilder directly like this:
imageBuilder: (context, imageProvider) {
return Image(
image: imageProvider,
width: size?.width,
height: size?.height,
fit: fit,
);
},