https://github.com/oxequa/flutter_cache_image
Flutter plugin to load and cache network or firebase storage images with a retry mechanism if the download fails
https://github.com/oxequa/flutter_cache_image
firebase-storage flutter flutter-firebase flutter-package flutter-plugin
Last synced: 3 months ago
JSON representation
Flutter plugin to load and cache network or firebase storage images with a retry mechanism if the download fails
- Host: GitHub
- URL: https://github.com/oxequa/flutter_cache_image
- Owner: oxequa
- License: gpl-3.0
- Created: 2018-08-12T20:31:49.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-05-21T00:04:02.000Z (about 3 years ago)
- Last Synced: 2023-08-20T21:30:19.791Z (almost 2 years ago)
- Topics: firebase-storage, flutter, flutter-firebase, flutter-package, flutter-plugin
- Language: Dart
- Homepage:
- Size: 110 KB
- Stars: 33
- Watchers: 3
- Forks: 25
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Flutter Cache Image
[](https://pub.dartlang.org/packages/cache_image)
A Flutter plugin to load and cache network or firebase storage images with a retry mechanism if the download fails.
This package supports the download of images from a standard *network path* and from a *firebase storage gs path*.Images are stored in the temporary directory of the app.
## Usage
To use this plugin, add firebase_storage as a dependency in your pubspec.yaml file.
```
dependencies:
cache_image: "^1.0.5"```
Import cache_image in a dart file:
```
import 'package:cache_image/cache_image.dart';
```To support firebase storage download the generated google-services.json file and place it inside android/app. Next, modify the android/build.gradle file and the android/app/build.gradle file to add the Google services plugin as described by the Firebase assistant.
## How to use
Cache Image can be used with any widget that support an ImageProvider.
``` dart
Image(
fit: BoxFit.cover,
image: CacheImage('gs://your-project.appspot.com/image.png'),
),
Image(
fit: BoxFit.cover,
image: CacheImage('https://hd.tudocdn.net/874944?w=646&h=284', duration: Duration(seconds: 2), durationExpiration: Duration(seconds: 10)),
),
FadeInImage(
fit: BoxFit.cover,
placeholder: AssetImage('assets/placeholder.png'),
image: CacheImage('gs://your-project.appspot.com/image.jpg')
)
```See the `example` directory for a complete sample app using Cache Image.