Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

errorWidget not working with most of network errors #932

Open
WaseemAbbasi22 opened this issue Mar 20, 2024 · 4 comments
Open

errorWidget not working with most of network errors #932

WaseemAbbasi22 opened this issue Mar 20, 2024 · 4 comments

Comments

@WaseemAbbasi22
Copy link

馃悰 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
Copy link

Same issue

1 similar comment
@aanari
Copy link

aanari commented Apr 11, 2024

Same issue

@NguyenHuy20
Copy link

NguyenHuy20 commented May 15, 2024

same issue
This bug only in Andoird

@ComputerHakka
Copy link

Same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants