blurhash_flutter 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 61

blurhash #

This library is a Blurhash algorithm implementation for dart. For more information or other implementations go to https://github.com/woltapp/blurhash.

Instead of showing boring placeholders, just show an idea of the picture while the actual picture is loading! Images can be converted to Base83 on your backend or while uploading in the frontend. Afterwards, you can send the Base83 string to your frontend. The client can then decode the Base83 string and draw the blurred image.

OriginalBlurred
Imageoriginaloriginal

Based on the hash q.NK3Mt7WrofayazbHj[l.TkCWBWCj[j@f6azIUWXjZWBWCjsoLayM{ofazayjZa#Wqj[kCWBj[bHWXj[jZWVt7WCs:ofa}axjZay

Example usage

See the example in example_main

original

Getting started #

Include the library in your project. Then call the decoder with a valid Base83 string

Image.memory(blurhash.Decoder.decode(hash, 300, 200))

Credits go to Dag Ă…gren / Wolt for this idea.

[0.1.0] - TODO: Add release date. #

  • Initial release with a decoder for blur hashes plus an example app

example/lib/example.dart

import 'package:blurhash/blurhash.dart' as blurhash;
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter blurhash',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter blurhash'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  // A correct blurhash
  static const hash =
      r"q.NK3Mt7WrofayazbHj[.TkCWBWCj[j@f6azIUWXjZWBWCjsoLayM{ofazayjZa#Wqj[kCWBj[bHWXj[jZWVt7WCs:ofa}axjZay";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Image.memory(blurhash.Decoder.decode(hash, 300, 200)),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  blurhash_flutter: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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_flutter/blurhash.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
61
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
test ^1.9.2