🖼️ Any Image View

Pub Version Pub Points Pub Likes License

Any Image View Demo

One widget to display them all! Network images, local files, SVGs, Lottie animations, and more — with built-in loading states, error handling, and smooth animations.

✨ Features

Feature Description
🌐 Network Images Best resolution with fade animations & HTTP headers support
📁 Local Files XFile & String paths from device
🎨 SVG & Lottie Vector graphics and animations (local assets)
🖼️ All Formats PNG, JPG, WebP, GIF, TIFF, RAW, HEIC, BMP, ICO
Shimmer Loading Built-in animated placeholder
🛡️ Error Handling Auto broken_image icon or custom widget
🔍 Pinch-to-Zoom Optional zoom & pan support

🚀 Quick Start

dependencies:
  any_image_view: ^1.9.5
import 'package:any_image_view/any_image_view.dart';

AnyImageView(
  imagePath: 'https://picsum.photos/300/200',
  height: 200,
  width: 300,
  borderRadius: BorderRadius.circular(12),
)

📖 Usage Examples

Network Image

AnyImageView(
  imagePath: 'https://example.com/image.jpg',
  height: 200,
  width: double.infinity,
  fit: BoxFit.cover,
)

Circular Avatar

AnyImageView(
  imagePath: user.avatarUrl,
  height: 80,
  width: 80,
  shape: BoxShape.circle,
  border: Border.all(color: Colors.blue, width: 2),
)

SVG Icon

AnyImageView(
  imagePath: 'assets/icons/logo.svg',
  height: 40,
  width: 40,
)

Lottie Animation

AnyImageView(
  imagePath: 'assets/animations/loading.json',
  height: 100,
  width: 100,
)

XFile (Image Picker)

AnyImageView(
  imagePath: pickedXFile, // XFile object directly
  height: 250,
  width: 250,
  borderRadius: BorderRadius.circular(15),
)

With Custom Loading & Error

AnyImageView(
  imagePath: imageUrl,
  height: 200,
  width: 200,
  placeholderWidget: CircularProgressIndicator(),
  errorWidget: Icon(Icons.error, color: Colors.red),
)

Authenticated Network Image

AnyImageView(
  imagePath: 'https://api.example.com/private/image.jpg',
  httpHeaders: {'Authorization': 'Bearer $token'},
  height: 200,
  width: 200,
)

Zoomable Image

AnyImageView(
  imagePath: 'assets/images/photo.jpg',
  height: 300,
  width: double.infinity,
  enableZoom: true,
)

🔧 API Reference

Parameter Type Default Description
imagePath Object? URL, asset path, file path, or XFile
height double? Container height
width double? Container width
fit BoxFit? cover How image fits in container
shape BoxShape rectangle rectangle or circle
borderRadius BorderRadius? Rounded corners
border BoxBorder? Border styling
boxShadow List<BoxShadow>? Shadow effects
margin EdgeInsets? Outer spacing
padding EdgeInsets? Inner spacing
onTap VoidCallback? Tap callback
placeholderWidget Widget? Shimmer Custom loading widget
errorWidget Widget? broken_image Custom error widget
fadeDuration Duration 400ms Fade animation duration
enableZoom bool false Pinch-to-zoom support
httpHeaders Map<String, String>? HTTP headers for network images
maxRetryAttempts int 3 Retry attempts for failed requests

📱 Platform Support

Android iOS Web macOS Windows Linux

🔄 Migration from Multiple Widgets

Before:

// Network
CachedNetworkImage(imageUrl: url, ...)
// File
Image.file(File(path), ...)
// SVG
SvgPicture.asset('icon.svg', ...)

After:

// All in one!
AnyImageView(imagePath: source, ...)

🤝 Support


Made with ❤️ by Farhan Sadik Galib
If this helps you, give it a ⭐ on pub.dev

Libraries

any_image_view