A Flutter widget for displaying network images with efficient caching.
This package provides a convenient way to display network images in your Flutter applications while taking advantage of caching to improve performance and reduce data usage.
-
Add the following dependency to your
pubspec.yaml
file:dependencies: icached_network_image: ^1.0.0 (or latest version)
-
Run
flutter pub get
to install the package.
Import the package in your Dart code:
import 'package:icached_network_image/icached_network_image.dart';
Use the ICachedNetworkImage
widget to display your network images:
ICachedNetworkImage(
'https://example.com/image.jpg',
height: 100,
width: 150,
placeholderAssetImage: 'assets/placeholder.png',
fit: BoxFit.cover,
),
- Caches downloaded images for faster loading in subsequent uses.
- Provides a placeholder image to display while the network image is loading.
- Supports local file paths for placeholder images.
- Allows customization of the image container's shape (rectangle, circle) and border.
- Offers flexibility in specifying image dimensions (height, width) and fit within the container.
- Handles checking and updating cached images to ensure they stay fresh.
height
: Controls the height of the image container (defaults to 50).width
: Controls the width of the image container (defaults to 50).placeholderAssetImage
: The asset path of the placeholder image.fit
: The fit of the image within its container (defaults toBoxFit.cover
). Can be anyBoxFit
value.alwaysShowPlaceHolder
: Set totrue
to always display the placeholder image, even when the network image is available (defaults tofalse
).shape
: The shape of the image container (defaults toBoxShape.circle
). Can beBoxShape.rectangle
orBoxShape.circle
.borderRadius
: The border radius of the image container (defaults tonull
).filePlaceholderPath
: The local file path of an alternative placeholder image (optional).border
: The border of the image container (optional). Use aBoxBorder
object to define the border style and color.
We welcome contributions to this package! Feel free to fork the repository on GitHub (https://github.com/MicroProgramer/icached_network_image), create pull requests for bug fixes or new features, and raise issues for any problems you encounter.
This package is licensed under the MIT License.