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

image_fade 封面
插件详情v0.6.2

image_fade

一个在图像加载时显示占位符和可选进度指示器,然后渐变为已加载图像的控件。对 FadeInImage 进行了改进。与 CachedNetworkImageProvider 兼容。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
7950
喜欢数
87
Pub 分数
150

安装插件

flutter pub add image_fade

插件介绍

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

ImageFade 是一个 Flutter 小部件,通过在图像完全加载前显示占位符和可选的进度指示器来增强图像加载体验。加载完成后,它会平滑地交叉淡入最终图像,提供流畅的视觉过渡效果。作为 FadeInImage 的改进版本,它支持 CachedNetworkImageProvider,并可在所有主要平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上运行。适用于需要在图像加载期间提供视觉反馈的应用程序。

适合场景

  • 加载图像并提供视觉反馈
  • 增强图像渲染期间的UI过渡效果
  • 在加载网络图片时显示占位符
  • 在图像密集型应用中提升感知性能
  • 使用缓存的网络图片
  • 创建平滑的图像淡入效果

主要特点

  • 图像加载时的交叉淡入淡出动画
  • 对占位符小部件的支持
  • 可选的进度指示器
  • 与 CachedNetworkImageProvider 的兼容性
  • 跨平台的平滑过渡
  • 轻量且易于集成

适合对象

  • 频繁加载图片的应用
  • 寻求更好图像加载用户体验的开发者
  • 使用 CachedNetworkImage 的项目
  • 以用户界面为重点的Flutter应用
  • 注重视觉效果的团队

使用建议

  • 需要额外设置进度指示器
  • 可能需要为占位符自定义样式
  • 不适合静态或非动态图像
  • 依赖外部图像缓存解决方案
  • 超出基本淡入淡出行为的自定义功能有限

原始 README

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

ImageFade

A widget for Flutter that displays a placeholder widget while a specified image loads, then cross-fades to the loaded image. Also handles progress and errors. It uses Image.opacity when appropriate for improved performance.

If image is changed, it will cross-fade to the new image once it is finished loading. Setting image to null will cross-fade back to the placeholder.

example image

You can set duration and curve, as well as most Image properties: width, height, fit, alignment, repeat, matchTextDirection, excludeFromSemantics and semanticLabel.

Use loadingBuilder and errorBuilder to display load progress or error states. Optionally specify syncDuration to use a different (usually faster) duration for fading in a synchronously loaded image, error, or placeholder.

ImageFade(
  // whenever the image changes, it will be loaded, and then faded in: 
  image: NetworkImage(url),

  // slow fade for newly loaded images:
  duration: const Duration(milliseconds: 900),

  // if the image is loaded synchronously (ex. from memory), fade in faster:
  syncDuration: const Duration(milliseconds: 150),

  // supports most properties of Image:
  alignment: Alignment.center,
  fit: BoxFit.cover,
  
  // shown behind everything:
  placeholder: Container(
    color: const Color(0xFFCFCDCA),
    alignment: Alignment.center,
    child: const Icon(Icons.photo, color: Colors.white30, size: 128.0),
  ),
  
  // shows progress while loading an image:
  loadingBuilder: (context, progress, chunkEvent) =>
    Center(child: CircularProgressIndicator(value: progress)),

  // displayed when an error occurs:
  errorBuilder: (context, error) => Container(
    color: const Color(0xFF6F6D6A),
    alignment: Alignment.center,
    child: const Icon(Icons.warning, color: Colors.black26, size: 128.0),
  ),
)

Image Caching

ImageFade is compatible with CachedNetworkImageProvider.

Installing

The published version of this package is availble on pub.dev.

Example

See the example directory for a simple example.

所属分类

源码仓库

使用此插件的项目