搜索插件、代码仓与 APP 分类

any_image_view 封面
插件详情v2.5.0

any_image_view

一个功能强大的Flutter图像查看器,支持PNG、JPG、WebP、GIF、TIFF、RAW、SVG、Lottie、XFile和网络图片,并提供最佳分辨率——所有功能集成于一个无缝的包中。

AndroidiOSmacOSWindowsLinux
近 30 天下载
649
喜欢数
100
Pub 分数
160

安装插件

flutter pub add any_image_view

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

AnyImageView 是一个全面的 Flutter 包,可简化显示各种图像格式(包括 PNG、JPG、WebP、GIF、TIFF、RAW、SVG 和 Lottie)以及网络和 XFile 图像。它会自动处理分辨率优化和跨平台渲染,确保高质量显示而无需额外配置。设计用于无缝集成,支持 Android、iOS、macOS、Windows 和 Linux,非常适合需要灵活且可靠的图像处理的应用程序。

适合场景

  • 在单个控件中显示多种图像格式
  • 从URL和本地文件加载图像
  • 支持 GIF 和 Lottie 等动画图像
  • 渲染矢量图形,如 SVG
  • 处理原始和高分辨率图像
  • 构建媒体画廊或图像密集型应用

主要特点

  • 支持多种图像格式(PNG、JPG、WebP、GIF、TIFF、RAW、SVG、Lottie)
  • 自动分辨率优化
  • 处理网络和 XFile 源
  • 跨平台兼容性
  • 简单的 API,设置简单
  • 内置缓存和错误处理

适合对象

  • 开发媒体丰富的应用程序的开发者
  • 需要支持动画或矢量图像的应用程序
  • 需要跨平台一致图像渲染的项目
  • 希望获得统一图像显示解决方案的团队
  • 具有不同图像源的原型或生产应用程序

使用建议

  • 由于包含格式解码器,可能会增加应用大小
  • 性能可能因大型或复杂的动画而有所不同
  • 对于长图像列表,需要仔细的内存管理
  • 高级图像处理的自定义功能有限
  • 不适用于图像编辑或转换

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

any_image_view

Pub Version License

Any Image View

Show any image with one widget. Network, asset, file, XFile, SVG or Lottie: hand it to AnyImageView and it takes care of loading, caching, retries and errors. Zero dependencies.

Install

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

Usage

// Network (cached on disk after the first load)
AnyImageView(imagePath: 'https://example.com/photo.jpg', height: 200, width: 200)

// Asset
AnyImageView(imagePath: 'assets/photo.png', height: 200, width: 200)

// SVG, asset or network, optionally tinted
AnyImageView(imagePath: 'assets/icon.svg', height: 40, width: 40, svgColor: Colors.blue)

// Lottie, loops automatically
AnyImageView(imagePath: 'assets/loader.json', height: 120, width: 120)

// Local file or image_picker result
AnyImageView(imagePath: '/path/to/photo.jpg', height: 200, width: 200)
AnyImageView(imagePath: pickedXFile, height: 200, width: 200)

// Circular avatar
AnyImageView(imagePath: url, height: 80, width: 80, shape: BoxShape.circle)

// Tap for a fullscreen viewer with pan, pinch and double-tap zoom
AnyImageView(imagePath: url, height: 200, width: 200, enableFullscreen: true)

// Styling and custom states
AnyImageView(
  imagePath: url,
  height: 200,
  width: 300,
  fit: BoxFit.cover,
  borderRadius: BorderRadius.circular(16),
  placeholderWidget: const CircularProgressIndicator(),
  errorWidget: const Icon(Icons.broken_image),
)

Supported formats

Type Formats
Raster PNG, JPG, WebP, GIF, BMP, ICO
Platform-decoded AVIF, HEIC on Android 12+, iOS 16+, macOS 13+ and web
Vector SVG
Animation Lottie .json, .zip, .lottie
Sources Network URL, asset, file path, file:// URI, XFile, File

The source is detected from the path. Matching is case-insensitive and ignores query strings and fragments.

Parameters

Parameter Type Default Purpose
imagePath Object? URL, asset path, file path, XFile or File
height, width double? Size
fit BoxFit? cover How the image fills the box (contain for SVG and Lottie)
alignment Alignment? Alignment inside the container
shape BoxShape rectangle rectangle or circle
borderRadius BorderRadius? Rounded corners
border BoxBorder? Border
boxShadow List<BoxShadow>? Shadows
margin, padding EdgeInsetsGeometry? Outer and inner spacing
placeholderWidget Widget? shimmer Shown while loading
errorWidget Widget? broken-image icon Shown on failure
fadeDuration Duration 400 ms Fade-in
maxRetryAttempts int 3 Retries after a failed network load; 0 disables
httpHeaders Map<String, String>? Headers for network requests
enableZoom bool false Inline pinch-to-zoom
enableFullscreen bool false Tap opens a fullscreen viewer
onTap VoidCallback? Custom tap handler
svgColor Color? Tint for SVGs
svgColorFilter ColorFilter? Custom SVG color filter

Screenshots

Network, PNG, SVG AVIF Lottie, avatar, error Fullscreen
Network image, PNG and SVG AVIF asset and network AVIF Lottie, circular avatar and error widget Fullscreen viewer

所属分类

源码仓库

使用此插件的项目