blurhash_dart 0.2.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

BlurHash Dart #

A pure dart implementation of BlurHash without any external dependencies (except for running tests) for maximum flexibility. Supports encoding and decoding. See 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 #

Decoding a BlurHash returns a raw array of pixels in RGBA32 format. You must convert the data to an image yourself. For this example we use the bitmap package to convert the pixel array to an bitmap, then to an ui.Image.

import 'package:blurhash_dart/blurhash_dart.dart';
import 'package:bitmap/bitmap.dart';

import 'dart:ui' as ui; // for displaying the image

String blurHash = "LEHV6nWB2yk8pyo0adR*.7kCMdnj";
Uint8List pixels = decodeBlurHash(blurHash, 35, 20);

Bitmap bitmap = Bitmap.fromHeadless(35, 20, pixels);
ui.Image image = await bitmap.buildImage();

Encoding a BlurHash #

For demo purposes we assume to have the popular image package installed, which decodes image files. The blurhash-dart API expects raw pixels in RGBA32 format for maximum flexibility.

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

Uint8List fileData = File("some_image.png").readAsBytesSync();
img.Image image = img.decodeImage(fileData.toList());

final blurHash = encodeBlurHash(
  image.getBytes(format: Format.rgba),


Changelog #

[0.2.3] 22.02.20 #

  • Make the analysis tool happy
  • Formatting

[0.2.2] 22.02.20 #

  • Fix minor style issues
  • Make the analysis tool happy by providing a longer description

[0.2.1] 22.02.20 #

  • Change import name as suggested by pub publish tool

[0.2.0] 22.02.20 #

  • Add support for encoding blurhashes
  • Decoder now returns raw pixels in RGBA32

[0.1.0] 21.02.20 #

  • First release


import 'dart:typed_data';

import 'package:blurhash_dart/blurhash_dart.dart';

void main() {
  String blurHash = "LEHV6nWB2yk8pyo0adR*.7kCMdnj";
  Uint8List pixels = decodeBlurHash(blurHash, 35, 20);
  print("Do something with the $pixels...");

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  blurhash_dart: ^0.2.3

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:blurhash_dart/blurhash_dart.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
image ^2.1.12
test ^1.12.0