Baseflow / Baseflow/flutter_cached_network_image

Add Timeout Support for CachedNetworkImage Requests

Open
#1,001 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
2.6k
Forks
731
Avg merge
3d 9h
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.