搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.2

progressive_blur

(實驗性) Flutter 中的漸進模糊實現。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2.2萬
喜歡數
68
Pub 分數
160

安裝套件

flutter pub add progressive_blur

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

漸進模糊是一種實驗性的Flutter套件,可實現圖像的平滑、逐步模糊效果,在圖像載入過程中提升視覺過渡與效能。它在圖像載入時逐步應用模糊,減少視覺突兀感並提高感知回應速度。專為圖像密集型應用設計,支援Android、iOS、Web、macOS、Windows及Linux等多個平台。該套件利用Flutter的渲染流程,以極低開銷提供高效、即時的模糊效果。適用於啟動畫面、圖像畫廊和動態UI,其中視覺連續性至關重要。

適用情境

  • 圖像加載帶有平滑過渡
  • 帶有模糊背景的啟動畫面
  • 動態圖像畫廊
  • 高性能UI動畫
  • 圖像渲染期間的視覺反饋

主要特色

  • 實驗性漸進模糊效果
  • 圖像加載期間的平滑視覺過渡
  • 跨平台支援(Android、iOS、Web、macOS、Windows、Linux)
  • 最小性能開銷
  • 與 Flutter 的渲染管道整合

適合對象

  • 開發圖像豐富應用程式的開發者
  • 尋求視覺精緻的UI設計師
  • 需要流暢加載體驗的應用
  • 實驗性功能測試
  • 注重性能的 Flutter 項目

使用建議

  • 實驗狀態可能暗示不穩定性
  • 可用的文件有限
  • 可能需要特定於平台的調整
  • 尚不建議用於生產關鍵功能
  • 模糊處理期間記憶體使用量更高

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Demo image

[!NOTE] Early version of the project. The performance may be suboptimal, and the APIs may change in the future.

An iOS-like progressive blur implementation for Flutter.

Usage

See the example folder for a complete example.

[!CAUTION] The CanvasKit web performance seems to be terrible. I'm not exactly sure why at the moment. However, skwasm performs much better.

import 'package:progressive_blur/progressive_blur.dart';

// Simple gradient blur with optional tint
ProgressiveBlurWidget(
  sigma: 24.0,
  linearGradientBlur: const LinearGradientBlur(
    values: [0, 1], // 0 - no blur, 1 - full blur
    stops: [0.5, 0.8],
    start: Alignment.topCenter,
    end: Alignment.bottomCenter,
  ),
  tintColor: Colors.orange.withOpacity(0.3), // Optional tint color
  child: ...
);

// Advanced: custom blur texture
//
// You can create a custom blur texture using the Flutter's Canvas API. Note that the red channel controls the blur strength (0 - no blur, 255 - full blur).
ProgressiveBlurWidget.custom(
  sigma: 24.0,
  blurTexture: [instance of ui.Image],
  tintColor: Colors.purple.withOpacity(0.4), // Optional tint color
  child: ...,
)

Rendering implementations

The package ships two implementations of the blur:

  • ImageFilter.shader (Impeller only): the two blur passes are applied as chained ui.ImageFilter.shader filters via an ImageFiltered widget. This avoids rendering the subtree into an intermediate ui.Image every frame. Requires Flutter 3.35+ and the Impeller rendering engine.
  • AnimatedSampler (fallback): the original implementation — the subtree is rendered into a composited layer and the resulting ui.Image is bound as a shader sampler. Works on Skia and on the web.

By default, the implementation is selected automatically at runtime via ui.ImageFilter.isShaderFilterSupported. You can override the selection with the static useImageFilter toggle:

// null (default): pick automatically — ImageFilter.shader on Impeller,
// AnimatedSampler otherwise.
ProgressiveBlurWidget.useImageFilter = null;

// Force the ImageFilter.shader implementation.
ProgressiveBlurWidget.useImageFilter = true;

// Force the AnimatedSampler implementation.
ProgressiveBlurWidget.useImageFilter = false;

The toggle can be changed at any time (existing widgets pick it up on their next rebuild), and both implementations render identically.

[!NOTE] With the ImageFilter.shader implementation, the blur parameters are read when the widget is built or its configuration changes — animating them every frame is not supported yet (see flutter/flutter#163302).

Additional information

Feel free to report bugs/issues on GitHub.

If you have questions, you can contact me directly at kk.erzhan@gmail.com.

Credits:

  • https://www.shadertoy.com/view/Mfd3DM - an inspiration for the blur shader
  • flutter_shaders - a great library for working with shaders in Flutter

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案