カテゴリー・パッケージ・リポジトリを検索

flutter_blurhash のカバー
パッケージ詳細v0.9.1

flutter_blurhash

画像のプレースホルダーのコンパクトな表現。Mediumが使用するように、30文字未満のぼかし画像をエンコードして即時表示

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
27.8万
いいね数
1720
Pub ポイント
160

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

flutter pub add flutter_blurhash

パッケージ概要

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

Flutter BlurHash は、BlurHash エンコーディングを使用して画像のコンパクトでリアルタイムのプレースホルダーを生成できる軽量パッケージです。画像のぼやけたバージョンを 30 文字未満の短い文字列にエンコードし、読み込み中に即座に表示可能になります。これは、画像が多く含まれるアプリでの認識されるパフォーマンス向上に最適です。エンコードされたハッシュは、実際の画像が読み込まれる前に、元の画像の色と構造を模倣する形で直接プレースホルダーとしてレンダリングできます。このアプローチは、Medium などのプラットフォームで広く利用されており、ユーザー体験を向上させるために活用されています。

用途

  • 画像の読み込みプレースホルダー
  • メディア重視のアプリにおけるパフォーマンス最適化
  • 画像の取得中に即時の視覚フィードバック
  • プログレッシブ画像レンダリング
  • 認識される読み込み時間を短縮する
  • オフライン画像プレビュー

主な機能

  • 超コンパクトなハッシュ表現
  • リアルタイムプレースホルダ生成
  • 色を保つぼかし効果
  • クロスプラットフォーム対応
  • 画像ウィジェットとの簡単な統合
  • 低帯域使用

適している対象

  • 多数の画像を含むアプリ
  • コンテンツフィード
  • ソーシャルメディアプラットフォーム
  • ECアプリ
  • スムーズな読み込みを重視するUI
  • 高速な画像プレースホルダを求める開発者

注意事項

  • 非常に短いハッシュでは詳細が限られる
  • 高精細なプレビューには適していません
  • クライアント側でのデコードが必要です
  • 低解像度のプレースホルダーに最適
  • 複雑なテクスチャを正確にマッチさせられない可能性があります
  • ハッシュは事前に計算するか、サーバーサイドで生成する必要があります

元の README

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

Flutter Community: flutter_blurhash

pub package Twitter

flutter_blurhash

Blurhash is compact representation of a blurred image. It's often used as a placeholder while waiting for a full image to load.

This package implements the blurhash-decoding algorithm in pure Dart. It also provides the BlurHash widget that displays the blurhash and can transition into the actual image once it is loaded.

Currently, it doesn't support encoding an image into a blurhash.

Generation

A fast and easy way to get a blurhash for your image is to upload it to https://blurha.sh.

Blurhash demo

Example

Constrain your widget's render area and let BlurHash fill the pixels.

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("BlurHash")),
        body: const SizedBox.expand(
          child: Center(
            child: AspectRatio(
              aspectRatio: 1.6,
              child: BlurHash(hash: "L5H2EC=PM+yV0g-mq.wG9c010J}I"),
            ),
          ),
        ),
      ),
    );
  }
}

Optimization Modes

  • None (BlurHashOptimizationMode.none): The original algorithm, provided for backward compatibility.
  • Standard (BlurHashOptimizationMode.standard): Optimized decoding with better cache locality and performance.
  • Approximation (BlurHashOptimizationMode.approximation): Fastest mode with an approximated sRGB conversion that produces slightly darker results but significantly improves performance.
class BlurHashApp extends StatelessWidget {
  const BlurHashApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => MaterialApp(
    home: Scaffold(
      appBar: AppBar(title: const Text("BlurHash")),
      body: const SizedBox.expand(
        child: Center(
          child: AspectRatio(
            aspectRatio: 1.6,
            child: BlurHash(
              hash: "L5H2EC=PM+yV0g-mq.wG9c010J}I",
              optimizationMode: BlurHashOptimizationMode.approximation,
            ),
          ),
        ),
      ),
    ),
  );
}

カテゴリー

ソースリポジトリ

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