Flutter never gave us a universal
<img>tag.any_imagedoes.
A universal Flutter image widget that automatically resolves and renders network, asset, and SVG images from a single source string. Designed to be extended, not modified.
Flutter gives you Image.network, Image.asset, SvgPicture.network, SvgPicture.asset — and expects you to know which one to use before rendering. In real apps, image sources arrive as opaque strings from APIs, CMSes, or databases. You shouldn't have to inspect the source to render it.
any_image handles that decision for you.
dependencies:
any_image: ^0.0.1flutter pub getimport 'package:any_image/any_image.dart';
// Network raster
AnyImage(source: 'https://example.com/photo.jpg')
// Network SVG
AnyImage(source: 'https://example.com/logo.svg')
// Asset raster
AnyImage(source: 'assets/images/banner.png')
// Asset SVG
AnyImage(source: 'assets/icons/logo.svg')That's it. any_image resolves the type and renders the correct widget automatically.
AnyImage(
source: imageUrl,
width: 200,
height: 200,
fit: BoxFit.cover,
placeholder: const CircularProgressIndicator(),
errorWidget: const Icon(Icons.broken_image),
)For sources where auto-resolution cannot determine the format (e.g. CDN URLs with no extension), use the format override:
AnyImage(
source: 'https://cdn.example.com/a8f3k',
format: ImageFormat.svg,
)any_image runs an ordered resolver pipeline on the source string:
- PrefixResolver — detects
assets/,http://,https:// - ExtensionResolver — detects
.svg,.png,.jpg,.webp,.gif
The resolved location and format are merged, then dispatched to the correct renderer:
| Location | Format | Renderer |
|---|---|---|
| network | raster | CachedNetworkImage |
| network | svg | SvgPicture.network |
| asset | raster | Image.asset |
| asset | svg | SvgPicture.asset |
any_image does not reimplement image rendering — it composes on top of cached_network_image and flutter_svg.
| Android | iOS | Web | macOS | Windows | Linux |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
- File image support (
Image.file,SvgPicture.file) - Global defaults via
AnyImageTheme - Custom renderer registry via
AnyImage.configure() - Builder API for custom loading states
- Fallback chained source support
Check out our roadmap here: Roadmap
Contributions are welcome. Please read CONTRIBUTING.md before opening a pull request.
MIT © Sameer Ankalagi