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

插件详情v0.0.1-dev.7

fast_blurhash

一个高性能的 Dart FFI 包,用于解码 BlurHash,利用 Rust 实现更快的处理速度。

AndroidiOSmacOSWindowsLinux
近 30 天下载
53
喜欢数
34
Pub 分数
150

安装插件

flutter pub add fast_blurhash

插件介绍

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

fast_blurhash 是一个高性能的 Dart FFI 包,通过利用 Rust 进行高效计算,加速 BlurHash 解码。它能够快速生成和渲染低分辨率占位图像,非常适合提升图像加载工作流程中的感知性能。通过将密集型操作卸载到原生 Rust 代码,相比纯 Dart 实现,显著降低了 CPU 开销。该包支持 Android、iOS、macOS、Windows 和 Linux 多个平台,适用于需要在图像加载期间提供流畅视觉反馈的跨平台应用。

适合场景

  • 快速图像占位符渲染
  • 改进的应用感知性能
  • 高效加载远程图像
  • 实时预览生成
  • 背景图像处理
  • 跨平台兼容性

主要特点

  • 基于 Rust 的高性能
  • Dart FFI 集成
  • 多平台支持
  • 低内存占用
  • 高速解码
  • 无缝的 Flutter 集成

适合对象

  • 加载大量图片的应用
  • 性能关键的UI
  • 图像密集型仪表板
  • 使用占位符进行原型设计
  • 寻求原生速度的开发者

使用建议

  • 本地构建需要 Rust 工具链
  • 仅限 BlurHash 解码(不包括编码)
  • 平台特定的原生依赖
  • CI/CD上的潜在构建复杂性
  • 可能会略微增加应用二进制文件大小

原始 README

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

fast_blurhash

A Dart FFI package project that uses Rust to decode the blurhash and encode the final image, utilizing FFI to call these functions. This package exists because it works +20x faster on average than the common Dart implementation and can be tested in release mode by running the benchmarks.dart demo.

It only works with the latest version of Flutter on the main branch and requires the following feature to be enabled: flutter config --enable-native-assets. For more details, refer to this issue.

Status

  • Uses experimental APIs which might change in the future.
  • The first time call takes longer than the average time so I have added a setup function to do a warmup call.
  • Tested only on iOS and MacOs in release mode.
  • Significant performance difference between release mode and debug mode; do not rely on debug mode results.

Project structure

This template uses the following structure:

  • rust: Contains the rust source code.

  • lib: Contains the Dart code that defines the API of the plugin, and which calls into the native code using dart:ffi.

Benchmarks

To test the performance of the package in release mode, run the benchmarks.dart demo.

So far I have tried this one iOS and macos release mode, don't run the benchmarks on debug mode.

Run the benchmark using : flutter run -t lib/benchmarks.dart --release

iPhone 15 pro:
screenshot from the benchmarks demo on iPhone 15 pro
M1 Macbook Pro:
screenshot from the benchmarks demo on macbook pro

所属分类

依赖

依赖清单 5 项

源码仓库

使用此插件的项目

暂无相关数据。