You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
馃悰 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
The text was updated successfully, but these errors were encountered: