Search categories, packages and repositories

Package detailsv1.2.1

blurhash_dart

A pure dart implementation of the BlurHash algorithm. This package provides both an encoder and a decoder, as well as some utility extensions.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
113K
Likes
135
Pub points
160

Install package

flutter pub add blurhash_dart

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

BlurHash Dart is a pure Dart implementation of the BlurHash algorithm, enabling efficient generation and decoding of compact image placeholders. It provides encoder and decoder functionality along with useful utility extensions for seamless integration into Flutter applications. Ideal for displaying low-bandwidth previews of images during loading, it supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux. The package is lightweight and designed for performance without external dependencies.

Use cases

  • Generating image placeholders during loading
  • Creating low-resolution previews for large images
  • Improving perceived app performance with placeholder visuals
  • Integrating blur effects in image thumbnails
  • Optimizing image loading in network-heavy apps

Key features

  • Pure Dart implementation
  • Encoder and decoder included
  • Utility extensions for ease of use
  • Cross-platform compatibility
  • Lightweight and fast
  • No native dependencies

Suitable for

  • Flutter developers needing image placeholders
  • Apps with slow or variable network conditions
  • Performance-focused UI implementations
  • Developers avoiding platform-specific code
  • Projects requiring minimal third-party libraries

Considerations

  • Not suitable for high-fidelity image representation
  • Requires understanding of BlurHash concept
  • Limited to placeholder use cases
  • May not support advanced image processing features
  • Best used as a visual enhancement, not a replacement for actual images

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

BlurHash Dart

A pure dart implementation of BlurHash. Supports both encoding and decoding. Runs on every supported Dart platform. See the BlurHash website or GitHub repository for more information.

The encoder of this dart implementation produces slightly different hashes than the TypeScript implementation but matches the official C and Python implementation. In practice this should not be relevant.

Basic usage

Decoding a BlurHash
import 'package:blurhash_dart/blurhash_dart.dart';
import 'package:image/image.dart' as img;

const hash = 'LEHV6nWB2yk8pyo0adR*.7kCMdnj';
BlurHash blurHash = BlurHash.decode(hash);
img.Image image = blurHash.toImage(35, 20);

// Display image...
Note: Usage with Flutter

Flutter does not expect raw bytes for its Image.memory widget, but fully encoded images with their corresponding headers (e.g. bitmap, jpg, png). The easiest way to accomplish this, is to use, for example, encodeJpg from package:image:

Widget build(BuildContext context) {
  final image = BlurHash.decode('LEHV6nWB2yk8pyo0adR*.7kCMdnj').toImage(35, 20);
  return Image.memory(Uint8List.fromList(encodeJpg(image)));
}

It is recommended to cache the resulting image in a stateful widget, such that it does not need to be recomputed on every build call.

Encoding an Image
import 'dart:io';

import 'package:blurhash_dart/blurhash_dart.dart';
import 'package:image/image.dart' as img;

final data = File('path/to/image.png').readAsBytesSync();
final image = img.decodeImage(data.toList());
final blurHash = BlurHash.encode(image!, numCompX: 4, numCompY: 3);

print(blurHash.hash);
Extension Methods

Additional extension methods to compute, for example color averages, are available when importing package:blurhash_dart/blurhash_extensions.dart. See example for basic usage.

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package