Baseflow / flutter_cached_network_image

Download, cache and show images in a flutter app
https://baseflow.com
2.4k stars 631 forks source link

errorWidget not working with most of network errors #932

Open WaseemAbbasi22 opened 2 months ago

WaseemAbbasi22 commented 2 months ago

🐛 Bug Report

When using the errorWidget property in Flutter to handle network errors, such as invalid image URLs or 403 errors, the errorWidget fails to display as expected. Instead, it throws exceptions, making it challenging to handle these specific network errors gracefully

Expected behavior

The errorWidget property should gracefully handle network errors, such as invalid URLs or 403 errors, by displaying a custom widget specified by the developer. It should not throw exceptions that disrupt the app's functionality or user experience.

Reproduction steps

Implement a Flutter widget that loads images from network URLs. Provide an invalid image URL or simulate a 403 error response from the server. Set up the errorWidget property to display a custom widget when network errors occur. Attempt to load the image using the invalid URL or simulate the 403 error. Observe that the errorWidget fails to display and instead throws exceptions.

Configuration

CachedNetworkImage( imageUrl: imageUrl ?? '', fit: BoxFit.cover, memCacheWidth: (250 * MediaQuery.of(context).devicePixelRatio).round(), placeholder: (context, url) => Center( child: SizedBox( height: 3.h, width: 6.w, child: const CircularProgressIndicator( color: AppColors.kWhiteColor, strokeWidth: 1, ), ), ), errorWidget: (context, url, error) { try { if (onLoadFailed != null) { onLoadFailed!(index); } } catch (e) { return Center( child: SizedBox( height: 3.h, width: 6.w, child: const CircularProgressIndicator( color: AppColors.kWhiteColor, strokeWidth: 1, ), ), ); // Handle the error gracefully, you can log it or show a different widget } return Center( child: SizedBox( height: 3.h, width: 6.w, child: const CircularProgressIndicator( color: AppColors.kWhiteColor, strokeWidth: 1, ), ), ); }, ) Version: 3.3.1

Platform: Android

ossomaster commented 2 months ago

Same issue

aanari commented 1 month ago

Same issue

NguyenHuy20 commented 2 weeks ago

same issue This bug only in Andoird

ComputerHakka commented 2 weeks ago

Same issue