Last updated:
0 purchases
flutter assets cache
Flutter Assets Cache #
This Dart package provides a convenient way to cache images and SVG assets in Flutter applications, supporting both local and network sources. It utilizes a custom cache manager to efficiently manage asset caching, reducing load times and improving app performance.
Features #
Caching of network images with a custom cache manager.
Support for both SVG and traditional image formats.
Placeholder widget display while images are loading.
Performance metrics logging for cache hits and misses.
Easy integration with existing Flutter projects.
Getting Started #
To use this package in your project, follow these steps:
Add the dependency: Include flutter_assets_cache in your pubspec.yaml file.
dependencies:
flutter_assets_cache: latest_version
copied to clipboard
Import the package: Add the following import to your Dart file.
import 'package:flutter_assets_cache/flutter_assets_cache.dart';
copied to clipboard
Use the getImageWidget function: Replace your image loading logic with calls to getImageWidget, specifying the image URL and any optional parameters like height, width, and fit.
Widget myImageWidget = getImageWidget(
'https://example.com/myimage.png',
height: 100,
width: 100,
fit: BoxFit.cover,
);
copied to clipboard
Example Usage #
Below is an example of how to use the getImageWidget function to load an image from a network source with caching:
class MyImageWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: getImageWidget(
'https://example.com/image.svg',
height: 200,
width: 200,
fit: BoxFit.fill,
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.