cached_any_image 0.1.2
cached_any_image: ^0.1.2 copied to clipboard
A cache-aware Flutter widget that renders both raster images and SVGs from a single API.
cached_any_image #
A cache-aware Flutter widget that renders both raster images (PNG/JPG/WebP, etc.) and SVGs from a single API, with disk caching, placeholders, error handling, headers, and rounded corners.
Features #
- One widget for SVG and raster (auto-detection, including when
.svg
extension is missing). - Disk caching via
flutter_cache_manager
. - Custom placeholders, error widgets, headers, rounded corners, and semantic labels.
- Supports
data:
URIs.
Install #
dependencies:
cached_any_image: ^0.1.0
Usage #
import 'package:cached_any_image/cached_any_image.dart';
import 'package:flutter/material.dart';
class Example extends StatelessWidget {
const Example({super.key});
@override
Widget build(BuildContext context) {
return ListView(
padding: const EdgeInsets.all(16),
children: const [
Text('SVG (via URL):'),
SizedBox(height: 8),
CachedAnyImage(
url: 'https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/android.svg',
width: 120,
height: 120,
fit: BoxFit.contain,
),
SizedBox(height: 24),
Text('Raster (via URL):'),
SizedBox(height: 8),
CachedAnyImage(
url: 'https://picsum.photos/600/300',
height: 160,
fit: BoxFit.cover,
),
],
);
}
}
Example #
Run the sample app:
cd example
flutter run
License #
MIT ©