flutter_blurhash

0.9.1

Compact representation of placeholder for an image. Encode a blurry image under 30 characters for instant display like used by Medium

Download archive

Readme

Flutter Community: flutter_blurhash

pub package Twitter

flutter_blurhash

Blurhash is compact representation of a blurred image, often used fo

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

It doesn't currently support encoding of Blurhash.

Generation

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

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,
            ),
          ),
        ),
      ),
    ),
  );
}
Changelog

0.9.1

  • Corrections

0.9.0

  • Performance by Raouf Rahiche

0.8.1

  • Code review

0.8.0

  • Flutter 3.0 as min required version

0.7.0

  • Add validateBlurhash() method

0.6.8

  • ImageNetwork can receive an errorBuilder

0.6.7

  • Rollback call to compute() and isolates as performances are down

0.6.6

  • Add headers for secure auth calls

0.6.4

  • onDecoded() and onDisplayed() events

0.6.2

  • package update

0.6.0

  • stable release for flutter 2.0

0.5.4-nullsafety.0

  • nullsafety.1

0.5.2-nullsafety.0

  • nullsafety.0

0.5.1

  • Update dependencies

0.5.0

  • Flutter Web compatibility thanks to @deakjahn

0.4.2

  • Remove dependency on Image package

0.4.1

  • Correction with Object Type method that is internal only

0.4.0

  • Direct ImageProvider by Rene Floor

0.3.0

  • Events registration to sync your animations

0.2.1

  • Automatic network image load with FadeIn Effect

0.2.0+3

  • Temporary removed ColoredBox until it lands on stable channel

0.2.0+2

  • Code cleanup

0.2.0

  • Cleaned up BlurHash Widget
  • Refactored and cleaned up decoder to a global method.
  • Moved package to Flutter Community

0.1.2

  • Performances and extended list as example

0.1.1

  • Documentation and cleanup

0.1.0

  • Released the decoder and basic widget

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add flutter_blurhash
pubspec.yaml
name: flutter_blurhash
description: >
  Compact representation of placeholder for an image.
  Encode a blurry image under 30 characters for instant display like used by Medium
version: 0.9.1
homepage: https://github.com/fluttercommunity/flutter_blurhash
repository: https://github.com/fluttercommunity/flutter_blurhash
issue_tracker: https://github.com/fluttercommunity/flutter_blurhash/issues
maintainer: Robert Felker (@Solido)

screenshots:
  - description: 'Content preview as blurred buffer.'
    path: screenshots/blurred.png
  - description: 'Content loaded.'
    path: screenshots/loaded.png

environment:
  # flutter: ">=3.16.0"
  sdk: ">=3.0.0 <4.0.0"

dependencies:
  flutter:
    sdk: flutter

dev_dependencies:

  flutter_lints:

  flutter_test:
    sdk: flutter

Version history

VersionPublishedArchiveSHA-256
0.1.0Cached · Upstream SHA-256 matchedDownloadd1abdaba…87110f
0.1.1Cached · Upstream SHA-256 matchedDownload098f93fa…430c48
0.1.2Cached · Upstream SHA-256 matchedDownload271cb270…6ae85e
0.2.0Cached · Upstream SHA-256 matchedDownload01fbfb39…769b39
0.2.0+1Cached · Upstream SHA-256 matchedDownload8dc220c1…43a653
0.2.0+2Cached · Upstream SHA-256 matchedDownloadbea51615…f1ba13
0.2.0+3Cached · Upstream SHA-256 matchedDownload3048c578…a66731
0.2.1Cached · Upstream SHA-256 matchedDownloadef86ce9b…fe8596
0.4.0Cached · Upstream SHA-256 matchedDownload0504357f…52849e
0.4.1Cached · Upstream SHA-256 matchedDownload7870b635…87fca6
0.4.2Cached · Upstream SHA-256 matchedDownloadb3bc4bbd…b78503
0.5.0Cached · Upstream SHA-256 matchedDownload339d896c…8a9230
0.5.2-nullsafety.0Cached · Upstream SHA-256 matchedDownload60d83750…e8a21c
0.5.4-nullsafety.0Cached · Upstream SHA-256 matchedDownload7aad8d0d…20590b
0.6.0Cached · Upstream SHA-256 matchedDownload3525f13a…d1f8c0
0.6.4Cached · Upstream SHA-256 matchedDownload1a4a4973…96a4ed
0.6.6Cached · Upstream SHA-256 matchedDownload933b9e6a…dec0d3
0.6.7Cached · Upstream SHA-256 matchedDownloadeb69353a…2c4d87
0.6.8Cached · Upstream SHA-256 matchedDownload93f1c766…44444d
0.7.0Cached · Upstream SHA-256 matchedDownload05001537…31a5c6
0.8.0Cached · Upstream SHA-256 matchedDownload0592f6ef…ad6bfe
0.8.1Cached · Upstream SHA-256 matchedDownload3af40992…4e5d11
0.8.2Cached · Upstream SHA-256 matchedDownload5e67678e…db0c06
0.9.0Cached · Upstream SHA-256 matchedDownloadd4724671…c2fb39
0.9.1Cached · Upstream SHA-256 matchedDownloade97b9aff…e3d25d

Dependencies

flutter { "sdk": "flutter" }