搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目