パッケージ、リポジトリ、アプリカテゴリを検索

blurhash_ffi のカバー
パッケージ詳細v1.2.7

blurhash_ffi

Flutter用のコンパクトで高速かつ使いやすいぼやけた画像プレースホルダ生成器。ネイティブなFFIバインディングを使用。

AndroidiOSmacOSWindowsLinux
30日間ダウンロード
3150
いいね数
107
Pub ポイント
130

パッケージをインストール

flutter pub add blurhash_ffi

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

blurhash_ffi は、ネイティブ FFI バインディングを使用してコンパクトで視覚的に魅力的なぼやけた画像プレースホルダーを生成する高性能な Flutter パッケージです。BlurHash 文字列を効率的にエンコードおよびデコードし、純粋な Dart 実装に依存せずに高速なプレースホルダー描画を可能にします。画像読み込み時の体感パフォーマンス向上に最適で、Android、iOS、macOS、Windows、Linux で動作します。視覚的品質を維持しながら、速度とメモリ使用量の最小化を重視しています。

用途

  • ロード画面のプレースホルダー
  • 画像ギャラリーのプレビュー
  • ネットワーク画像の読み込みインジケーター
  • オフラインコンテンツのプレースホルダー
  • メディア重視のアプリにおけるパフォーマンス最適化

主な機能

  • ネイティブ FFI パフォーマンス
  • クロスプラットフォーム対応
  • コンパクトハッシュエンコーディング
  • 高速デコード
  • メモリ使用量が小さい

適している対象

  • 大量の画像を読み込むアプリ
  • 高パフォーマンスUI要件
  • ネイティブスピードを求める開発者
  • 軽量なプレースホルダが必要なプロジェクト
  • マルチプラットフォームのFlutterアプリ

注意事項

  • ネイティブコンパイルのセットアップが必要です
  • BlurHash形式のみに制限
  • アプリのサイズがわずかに増える可能性があります
  • 複雑な画像処理には適していません
  • プラットフォーム固有の FFI ライブラリに依存しています

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

blurhash_ffi

A Blurhash compact Image placeholder encoder and decoder FFI implementation for Flutter in Rust via experemental feature Native Assets.

Matches the official Blurhash implementation in performance and quality.

blurhash_ffi

Supports

Platform Status Description
Android ✅ -
iOS ✅ -
macOS ✅ -
Linux ⚠️ Not tested
Windows ✅ -
Web ❌ Rust can compiled to WebAssembly, but no supported yet. This library compiled on standalone wasm module (not in Empscripten, AssemblyScript) that Dart can't be use non-JS enviroments. Also, Dart should use FFI bindings for call wasm module. Stopped issues: comment

Installation

Add dependency to your pubspec.yaml file following the command below:

For dart projects:

dart pub add dart_blurhash_ffi

For flutter projects:

dart pub add flutter_blurhash_ffi

Usage

To use this plugin, add blurhash_ffi as a dependency in your pubspec.yaml file

Flutter usage

import 'package:flutter_blurhash_ffi/flutter_blurhash_ffi.dart';

/// Encoding and Decoding all in One Step
///
/// `ImageProvider` in    -> Send your Image to be encoded.
/// `ImageProvider` out   -> Get your blurry image version.
class BlurhashMyImage extends StatelessWidget {
  final String imageUrl;
  const BlurhashMyImage({required this.imageUrl, super.key});

  @override
  Widget build(BuildContext context) {
    return Image(
      image: BlurhashFfiImage.fromImageProvider(
        NetworkImage(imageUrl),  // you can use any image provider of your choice.
        decodingHeight: 1920,
        decodingWidth: 1080,
      ),
      alignment: Alignment.center,
      fit: BoxFit.cover
    );
  }
}


class BlurhashMyImage2 extends StatelessWidget {
  final String blurhash;
  const BlurhashMyImage2({required this.blurhash, super.key});

  @override
  Widget build(BuildContext context) {
    return Image(
      image: BlurhashFfiImage(blurhash),
      width: 200,
      height: 200,
      alignment: Alignment.center,
      fit: BoxFit.cover
    );
  }
}

[!WARNING] Not recommend use it (without blurhash string param), because in this case, encoding and decoding will be performed. This effect can be obtained almost through ImageFiltered.

Encoding

Encoding now uses sync interface (without Future).

import 'package:dart_blurhash_ffi/dart_blurhash_ffi.dart';

final Uint8List blurhashImageBytes = File('assets/image.webp').readAsBytesSync();

/// Signature
/// static String encode(
///   Uint8List data, {
///   int componentX = 4,
///   int componentY = 3,
/// })
/// may throw `BlurhashFFIException` if encoding fails.
final String blurHash = BlurhashFFI.encode(blurhashImageBytes);

// Or via codec

final String blurHashSame = BlurhashFfiCodec().encoder.convert(blurhashImageBytes);

Decoding

Decoding now uses sync interface (without Future).

import 'package:dart_blurhash_ffi/dart_blurhash_ffi.dart';

final String blurhash = 'LGFO~6Yk^6#M@-5c,1Ex@@or[j6o';

/// Signature
///
/// static Uint8List decode(
///   String blurhash, {
///   int width = 32,
///   int height = 32,
///   int punch = 1,
/// })
/// may throw `BlurhashFFIException` if decoding fails.
final decoded = BlurhashFFI.decode(blurhash);

// or via codec

final String decodedSame = BlurhashFfiCodec().decoder.convert(blurhash);

Check the example for more details

contributions in the form of PR's and Issues are a welcome

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。