cached_any_image

pub package CI

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 ©

Libraries

cached_any_image
CachedAnyImage – a single widget that renders both raster images (PNG/JPG/WebP, etc.) and SVGs from the same URL API, with disk caching for both.