搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案