any_image 0.0.1 copy "any_image: ^0.0.1" to clipboard
any_image: ^0.0.1 copied to clipboard

A universal Flutter image widget that renders any source

any_image #

Flutter never gave us a universal <img> tag. any_image does.

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.

pub.dev License: MIT Platform


The problem #

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.


Installation #

dependencies:
  any_image: ^0.0.1
flutter pub get

Usage #

Basic #

import '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.

With options #

AnyImage(
  source: imageUrl,
  width: 200,
  height: 200,
  fit: BoxFit.cover,
  placeholder: const CircularProgressIndicator(),
  errorWidget: const Icon(Icons.broken_image),
)

Override resolution #

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,
)

How it works #

any_image runs an ordered resolver pipeline on the source string:

  1. PrefixResolver — detects assets/, http://, https://
  2. 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.


Platform support #

Android iOS Web macOS Windows Linux

Roadmap #

  • ❌ 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

Contributing #

Contributions are welcome. Please read CONTRIBUTING.md before opening a pull request.


License #

MIT © Sameer Ankalagi

2
likes
150
points
84
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A universal Flutter image widget that renders any source

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

cached_network_image, flutter, flutter_svg

More

Packages that depend on any_image