multi_network_image
is a package that allows you to handle adaptive images with ease.
Status | Comments |
---|---|
Current stable Flutter version | |
Current beta Flutter version | |
The oldest supported Flutter version |
- Add this package to your dependencies.
dependencies:
multi_network_image: latest_version
- Get the dependencies.
flutter pub get
- Use
MultiNetworkImage
as a source for yourImage
.
return Image(
image: MultiNetworkImage([
// The main image that we want to display.
'https://picsum.photos/2000',
// You can provide additional images that will be used
// as a fallback if the main image is not available.
'https://picsum.photos/200',
// The low-quality image that, if cached, will be used
// as a placeholder.
'https://picsum.photos/20',
]),
);
MultiNetworkImage
will look for the first image that is both provided in the list and is cached, and will use it as an initial source.
After that (or if no image is cached), it will try to fetch the first image from the list. If it fails, it will try the next one, and so on.
It allows you to provide a low-quality image as a fallback, and a high-quality image as a primary source.
- This package requires at least Flutter 3.27.0 to work.
- If there are any issues feel free to go to GitHub Issues and report a bug.