Skip to content

Commit 54eee1c

Browse files
committed
copy readme to root folder
1 parent 454ce5e commit 54eee1c

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Cached network image
2+
[![pub package](https://img.shields.io/pub/v/cached_network_image.svg)](https://pub.dartlang.org/packages/cached_network_image)
3+
[![codecov](https://codecov.io/gh/Baseflow/flutter_cached_network_image/branch/master/graph/badge.svg?token=I5qW0RvoXN)](https://codecov.io/gh/Baseflow/flutter_cached_network_image)
4+
[![Build Status](https://github.com/Baseflow/flutter_cached_network_image/workflows/app_facing_package/badge.svg?branch=develop)](https://github.com/Baseflow/flutter_cached_network_image/actions/workflows/app_facing_package.yaml)
5+
6+
A flutter library to show images from the internet and keep them in the cache directory.
7+
8+
## How to use
9+
The CachedNetworkImage can be used directly or through the ImageProvider.
10+
Both the CachedNetworkImage as CachedNetworkImageProvider have minimal support for web. It currently doesn't include caching.
11+
12+
With a placeholder:
13+
```dart
14+
CachedNetworkImage(
15+
imageUrl: "http://via.placeholder.com/350x150",
16+
placeholder: (context, url) => CircularProgressIndicator(),
17+
errorWidget: (context, url, error) => Icon(Icons.error),
18+
),
19+
```
20+
21+
Or with a progress indicator:
22+
```dart
23+
CachedNetworkImage(
24+
imageUrl: "http://via.placeholder.com/350x150",
25+
progressIndicatorBuilder: (context, url, downloadProgress) =>
26+
CircularProgressIndicator(value: downloadProgress.progress),
27+
errorWidget: (context, url, error) => Icon(Icons.error),
28+
),
29+
```
30+
31+
32+
````dart
33+
Image(image: CachedNetworkImageProvider(url))
34+
````
35+
36+
When you want to have both the placeholder functionality and want to get the imageprovider to use in another widget you can provide an imageBuilder:
37+
```dart
38+
CachedNetworkImage(
39+
imageUrl: "http://via.placeholder.com/200x150",
40+
imageBuilder: (context, imageProvider) => Container(
41+
decoration: BoxDecoration(
42+
image: DecorationImage(
43+
image: imageProvider,
44+
fit: BoxFit.cover,
45+
colorFilter:
46+
ColorFilter.mode(Colors.red, BlendMode.colorBurn)),
47+
),
48+
),
49+
placeholder: (context, url) => CircularProgressIndicator(),
50+
errorWidget: (context, url, error) => Icon(Icons.error),
51+
),
52+
```
53+
54+
## How it works
55+
The cached network images stores and retrieves files using the [flutter_cache_manager](https://pub.dartlang.org/packages/flutter_cache_manager).
56+
57+
## FAQ
58+
### My app crashes when the image loading failed. (I know, this is not really a question.)
59+
Does it really crash though? The debugger might pause, as the Dart VM doesn't recognize it as a caught exception; the console might print errors; even your crash reporting tool might report it (I know, that really sucks). However, does it really crash? Probably everything is just running fine. If you really get an app crashes you are fine to report an issue, but do that with a small example so we can reproduce that crash.
60+
61+
See for example [this](https://github.com/Baseflow/flutter_cached_network_image/issues/336#issuecomment-760769361) or [this](https://github.com/Baseflow/flutter_cached_network_image/issues/536#issuecomment-760857495) answer on previous posted issues.

0 commit comments

Comments
 (0)