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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Timeout Support for CachedNetworkImage Requests #1001

Open
nifra-s opened this issue Jan 26, 2025 · 0 comments
Open

Add Timeout Support for CachedNetworkImage Requests #1001

nifra-s opened this issue Jan 26, 2025 · 0 comments

Comments

@nifra-s
Copy link

nifra-s commented Jan 26, 2025

Hi,

First of all, thank you for this amazing package! It's very useful and widely appreciated in the Flutter community.

I would like to request a feature to add timeout support for image requests in the CachedNetworkImage widget.
Problem:

Currently, there is no built-in way to configure a timeout for image requests. This can lead to scenarios where the widget keeps trying to load an image indefinitely, especially on slower networks or when the server is unresponsive.
Proposed Solution:

It would be great to have a property like timeout in the CachedNetworkImage widget, where users can specify the maximum time (in milliseconds) the widget should wait for the image to load. If the timeout is exceeded, the widget could show an errorWidget or placeholder.

For example:

CachedNetworkImage(
  imageUrl: "https://example.com/image.jpg",
  timeout: Duration(seconds: 5), // Custom timeout
  errorWidget: (context, url, error) => Icon(Icons.error),
  placeholder: (context, url) => SkeletonLoader(), // Optional
);

Benefits:

  • Better user experience: Users will no longer experience indefinite loading times.
  • More control: Developers can adjust the timeout based on the app's needs.
  • Aligns with modern practices: Most networking libraries offer timeout configuration.
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

1 participant