photo_view
photo_view copied to clipboard
Question: How to reload failed image?
I have this piece of code
return Stack(
children: [
Container(
decoration: BoxDecoration(color: Colors.black.withOpacity(0.90)),
constraints: BoxConstraints.expand(
height: MediaQuery.of(context).size.height,
),
child: PhotoViewGallery.builder(
pageController: _controller,
backgroundDecoration: BoxDecoration(color: Colors.transparent),
scrollPhysics: const BouncingScrollPhysics(),
builder: (BuildContext context, int index) {
return PhotoViewGalleryPageOptions(imageProvider: CachedNetworkImageProvider(_arguments.images[index].image), onTapDown: (_, __, ___) => close(context));
},
itemCount: _arguments.images.length,
loadingBuilder: (context, chunkEvent) => CupertinoActivityIndicator(radius: 16,),
onPageChanged: (i) => setState(() => _page = i + 1),
),
)
]
);
What is the best way to reload image if one of the images fails to load (due to connectivity issue)? I played with the CachedNetworkImageProvider
's cache, refreshing the _arguments.images
but nothing worked.
Thanks.
That is a very good question!
I never had to do it, but I guess a solution would have to be provided by the image provider (pun unintended). We have an open issue on https://github.com/Baseflow/flutter_cached_network_image/issues/468 that may help we figure out something on our side.