Compact representation of a placeholder for an image. Encode a blurry image under 30 caracters for instant display like used by Medium. Maintainer: @Solido

Overview

Flutter Community: flutter_blurhash

pub package Twitter

Flutter BlurHash

Compact representation of a placeholder for an image.

Generation

Capture d’écran 2020-02-21 à 19 11 56

You can use https://blurha.sh/ for testing or use any official api on your server side.

Flutter Code

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

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"),
          ),
        ),
      ),
    ),
  );
}
Comments
  • Add BlurHash encoding

    Add BlurHash encoding

    There are some use-cases where it is useful to perform encoding on the device, e.g. when sending large images using e2e encryption.

    Adding encoding to this package would support that use case without including another dependency. I'm not too familiar with the BlurHash algorithm but I suspect this wouldn't add much code to the implementation.

    For reference, here's the blurhash_dart implementation, which itself has no dependencies: https://github.com/justacid/blurhash-dart/blob/master/lib/src/blurhash.dart#L70

    opened by cachapa 12
  • Encoding BlurHash from Image in dart

    Encoding BlurHash from Image in dart

    First of all thank you for introducing us Flutter community with this great tool. It is a game changer. For this to reach to broader developers I think we should be able to encode the image to it's corresponding blurhash string. Are you planning on writing a function which does this on the client. This way we can upload the image along with the blurhash to Firestore and Firebase Storage at the same time. People might not be using server side code(cloud functions) since they will bring extra pricing/delay/performance issues. If this is not a good way, then I hope someone would show an cloud function example in type script.

    opened by aytunch 10
  • Remove dependency on

    Remove dependency on "image" package.

    As we discussed it with Rene at https://github.com/Baseflow/flutter_cached_network_image/issues/386, there is no need to depend on image for the conversion of pixel data to image, the Skia inside the Flutter framework can do it directly. These are the necessary changes. It works on mobile, I still have some problems on Flutter Web (it looks like ui.decodeImageFromPixels() simply never returns), so expect more to come.

    Sorry for the inclusion of class Style, I don't know how Android Studio pulled that off. I simply forked, modified, committed and pushed. :-)

    opened by deakjahn 5
  • Does not work on web

    Does not work on web

    Hello. Very nice package, but it is not working on web even stated so in https://pub.dev/packages/flutter_blurhash

    I noticed you closed an issue 20 days ago about this, but not before fooling a lot around with the package as it was supposed to work on web.

    Could you remove the web compability notice on the package listing until the flutter web framework is compatible....?

    opened by PsychTechApS 4
  • BlurHash widget does not have an error attribute

    BlurHash widget does not have an error attribute

    If you run into an exception trying to download the image (e.g. connection timeout due to bad connection) a red cross with the error message will be shown ontop of the blurhash image. Currently there is no way to disable this behaviour (I'd rather stick with the blur hash over having this ugly cross) or to set a custom error image.

    opened by sentd94 3
  • Workaround for Flutter issue

    Workaround for Flutter issue

    Temporary workaround for https://github.com/flutter/flutter/issues/45190

    On the web, there are various issues with Skia async functions no returning. As I mentioned in that thread, I suspect the HtmlCodec to be at fault. Until such time as this is fixed, I present the following workaround: on Flutter Web, we can create a BMP image on the fly. Considering the small size of the blurhash image, there is really no need for the compression that PNG or JPG could provide, so this is the cheapest temporary solution.

    opened by deakjahn 3
  • Can't compile

    Can't compile

    Using your exemple project with flutter_blurhash: ^0.4.0, I can't compile on Android :

    Compiler message:
    /C:/ProgramData/Flutter/.pub-cache/hosted/pub.dartlang.org/flutter_blurhash-0.4.0/lib/src/blurhash_image.dart:76:10: Error: The method 'objectRuntimeType' isn't defined for the class 'BlurHashImage'.
     - 'BlurHashImage' is from 'package:flutter_blurhash/src/blurhash_image.dart' ('/C:/ProgramData/Flutter/.pub-cache/hosted/pub.dartlang.org/flutter_blurhash-0.4.0/lib/src/blurhash_image.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'objectRuntimeType'.
          '${objectRuntimeType(this, 'BlurHashImage')}(${describeIdentity(blurHash)}, scale: $scale)';
             ^^^^^^^^^^^^^^^^^
    Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
    build failed.
    
    FAILURE: Build failed with an exception.
    

    Any idea how to fix this ?

    opened by Nico04 3
  • Version 0.6.6 -  Huge memory consumption and Crash

    Version 0.6.6 - Huge memory consumption and Crash

    After Upgrading from 0.6.4 to 0.6.6,

    I noticed huge lag while scrolling into multiple images that use BlurHash as loading widget.

    I also noticed significant memory consumption and multiple _spawn stacks being generated.

    Reverting back to 0.6.4 fixes the issue.

    opened by YDA93 2
  • [Feature] add header for download image

    [Feature] add header for download image

    Hi, and thank u for such a good library!

    In my case image on server protected by auth token which should be passed in the Header. Since blurhash used Image.network under the hood now it is impossible to pass token.

    Seems like to reach this goal at the BlurHashState.prepareDisplayedImage instead of Image.network we need use:

    Image(
        image: NetworkImage(
        imagePath,
        headers: {
          HttpHeaders.authorizationHeader: 'token',
        },
    ),
    

    Let me know what u thinking and i can help with implementation

    opened by beerline 2
  • Background issue on PNG image

    Background issue on PNG image

    I am using blurha.sh as mentioned on documentation. While using PNG image, hash effect is still visible on background,

    image

    Top image is using BlurHash and bottom one using Image.network. For some images I like this effect but for some not. How can get the original image after loading like Image.network.

    
    class MyHomePage extends StatelessWidget {
      const MyHomePage({Key? key}) : super(key: key);
    
      final imageUrl =
          "https://flutter.dev/assets/images/homepage/garden-logos-color/google.png";
      final hash =
          "rOByL6JFEoCA,koaRX\$IS~X8kFo#jXfnf*adf,fP0yxC\${+[I^W=otNarqogkEbdbHfRjXW9jDacj]bcoLjXWVjXW,b0WCs;W.jZWqnzWAjXacjr";
    
      @override
      Widget build(BuildContext context) {
        return Column(
          children: [
            AspectRatio(
              key: const ValueKey("GBH"),
              aspectRatio: 200 / 67,
              child: BlurHash(
                hash: hash,
                image: imageUrl,
                color: Colors.green,
              ),
            ),
            Image.network(
              imageUrl,
              key: const ValueKey("GMN"),
            )
          ],
        );
      }
    }
    
    
    [√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version
        10.0.19043.1348], locale en-US)
        • Flutter version 2.5.3 at C:\Tools\flutter
        • Upstream repository https://github.com/flutter/flutter.git      
        • Framework revision 18116933e7 (4 weeks ago), 2021-10-15 10:46:35      -0700
        • Engine revision d3ea636dc5
        • Dart version 2.14.4
    
    opened by yeasin50 2
  • Flutter web canvaskit crash  in flutter master 2.6.0 version

    Flutter web canvaskit crash in flutter master 2.6.0 version

    When read blur hash widget, there is error as below: ════════ Exception caught by scheduler library ═════════════════════════════════ The following assertion was thrown during a scheduler callback: Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/canvaskit/skia_object_cache.dart:248:12 !browserSupportsFinalizationRegistry is not true

    Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel master, 2.6.0-6.0.pre.146, on macOS 11.0.1 20B29 darwin-x64, locale zh-Hant-TW) [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3) ✗ cmdline-tools component is missing Run path/to/sdkmanager --install "cmdline-tools;latest" See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run flutter doctor --android-licenses to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 12.5.1) [✓] Chrome - develop for the web [✓] Android Studio (version 3.6) [✓] VS Code (version 1.60.1) [✓] Connected device (1 available)

    opened by skypu3 2
  • Added suport for colorBlendMode

    Added suport for colorBlendMode

    We need colorBlendMode in order to build optimized apps and avoid using Opacity Widget above it

    https://docs.flutter.dev/perf/ui-performance#identifying-problems-in-the-gpu-graph

    opened by prologikus 0
  • Universal BlurHash widget

    Universal BlurHash widget

    Remote resource to download image is very specific way to use BlurHash widget. Images could be loaded in many different ways using different protocols. Could be nice to make BlurHash widget universal.

    opened by zs-dima 0
  • Get the hash from an image?

    Get the hash from an image?

    Hi friends,

    I have an issue with flutter_blurhash, how to get the hash code from an image in Flutter? I can't find any details for this :(

    Thanks in advance!

    opened by RoyalCoder88 2
  • Fixed Cannot clone a disposed image

    Fixed Cannot clone a disposed image

    Because Image widget in buildBlurHashBackground does not have errorBuilder, its causing the framework to throw errors as per issues:

    1. https://github.com/fluttercommunity/flutter_blurhash/issues/46
    2. https://github.com/fluttercommunity/flutter_blurhash/issues/40

    Since buildBlurHashBackground is widget function instead of stateless widget this made it even harder to trace where the error is coming from.

    Which was pointing to Flutter image widget only, which I think it should include buildBlurHashBackground too.

    Please Refer to:

    Stackoverflow

    Flutter issue 19269

    If you look at flutter image widget at image.dart line 1141:

    assert(() {
      if (widget.errorBuilder == null) {
        // ignore: only_throw_errors, since we're just proxying the error.
        throw error; // Ensures the error message is printed to the console.
      }
      return true;
    }());
    

    Long story short:

    Your code does not produce this error, our code does. Your code only does not enable us to handle it.

    Kindly merge this.

    Thanks,

    opened by YDA93 9
  • Cannot clone a disposed image

    Cannot clone a disposed image

    I know this is a duplicated issue.

    Please consider a fix. Its causing headache while in development (non fatal exception). As well as in production it's sending so many reports to Crashlytics.

    Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Bad state: Cannot clone a disposed image.
    The clone() method of a previously-disposed Image was called. Once an Image object has been disposed, it can no longer be used to create handles, as the underlying data may have been released.. Error thrown Instance of 'ErrorDescription'.
           at Image.clone(Image.java)
           at ImageInfo.clone(image_stream.dart:51)
           at ImageStreamCompleter.setImage(image_stream.dart:635)Ï
    

    Screen Shot 2022-04-21 at 10 38 12 PM

    opened by YDA93 1
Owner
Flutter Community
A central place for all community made Flutter packages. To get started, see the README of the 'community' repository.
Flutter Community
A discord bot, made with Dart, which lets you run your own pure Dart code snippets directly via a discord ping, and get the output in an instant.

A discord bot, made with Dart, which lets you run your own pure Dart code snippets directly via a discord ping, and get the output in an instant.

Anikate De 3 Oct 21, 2022
Web development for smartgreen's RYO-OHKI Project, should contain: a login page, import, export and visualization of cards (almost a dashboard) it is under construction!

Web development for smartgreen's RYO-OHKI Project, should contain: a login page, import, export and visualization of cards (almost a dashboard) it is under construction!

Beatriz gonçalves 6 Nov 13, 2021
A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority

A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority, such as a government or bank, to uphold or maintain it.

Prashant Kumar Singh 10 Dec 3, 2022
Flutter representation of a Restaurant app UI.

?? Foodybite Flutter representation of a Restaurant app UI i found in Uplabs. It only consists of 2 screens. Star ⭐ the repo if you like what you see

Festus Olusegun 1.3k Jan 2, 2023
Flutter representation of a Crypto app Concept

?? ?? Flutter Cryptocurrency app Concept Flutter representation of a Crypto app Concept from Uplabs. Star ⭐ the repo if you like what you see ?? . Ima

Festus Olusegun 185 Dec 29, 2022
Page Turn Widget - Add a page turn effect to widgets in your app. Maintainer: @rodydavis

Page Turn Widget Add a page turn effect to widgets in your app. Created by Simon Lightfoot @slightfoot Screenshots Example import 'package:flutter/mat

Flutter Community 177 Dec 29, 2022
A Flutter plugin to retrieve and manage contacts on Android and iOS devices. Maintainer: @lukasgit

contacts_service A Flutter plugin to access and manage the device's contacts. Usage To use this plugin, add contacts_service as a dependency in your p

Lukas Dickie 166 Dec 28, 2022
To cure symptoms of various disease using medicines at home this app will act as guideline. Few animations are used and Firebase is used as database.

Medkit It's a Pharmacy application that help you in curing basic symptoms and diseases with medicines available in your home. How to Run Code Clone or

Muhammad Hamza 109 Dec 22, 2022
Sorting Visualizer using Flutter followed MVVM Pattern and used Stacked Services. Hope you like it 😋

Sortlizer An App to visualize various sorting algorithms...Developed using Flutter, followed MVVM pattern, and used stacked services. Play Store Link

Roshan Kumar 17 Dec 28, 2022
A mobile image uploader in which you can upload image to your personal gallery from either your camera or mobile gallery and it can detect your current geographic location and address using firebase firestore and storage.

Image Uploader In Flutter About It is an Image Uploader gallery which tracks your address from which you're uploading using Flutter and Image picker.

Prahen parija 6 Dec 20, 2022
App can detect COVID via X-Ray image, just use some sample image available in the listed links.

Covid19detector : Detecting COVID-19 from X-Ray ?? App can detect COVID via X-Ray image, just use some sample image available in the listed links. And

Sanskar Tiwari 21 Jun 14, 2022
This pub lets you share any kind of files (csv, mp4, png etc), take screenshot of the widgets you want and return as Image and share them directly as well in the form of an image.

share_files_and_screenshot_widgets This pub lets you share any kind of files (csv, mp4, png etc), take screenshot of the widgets you want and return a

Jay Mehta 22 Dec 28, 2022
The FlexGrid control provides a powerful and quickly way to display data in a tabular format. It is including that frozened column/row,loading more, high performance and better experience in TabBarView/PageView.

flex_grid Language: English| 中文简体 The FlexGrid control provides a powerful and quickly way to display data in a tabular format. It is including that f

FlutterCandies 39 Nov 8, 2022
Flutter Widget to display PDF

pdf_flutter Inspired by Pdf_Viewer_Plugin ?? Wrapped around AndroidPdfViewer on Android. ???? 1. Add pdf_flutteron pubspec.yml dependencies: pdf_flu

Laxman Bhattarai 100 Sep 7, 2022
display a Dart string in Flutter using simple rich text characters

simple_rich_text Easily format Flutter text with simple format characters. Motivation: lowest-possible development friction to add color and formattin

Peter Alvin 16 Dec 5, 2022
A flutter package which contains a collection of Splash Screen example for your app to display logo and different text style.

splash_screen_view They say, first impression is the last! Yep, truly for any amazingly crafted application, it's easier to start impressing your audi

Sandip Kalola (SK) 17 Nov 25, 2022
📱🌦 Flutter application to display PWS (Personal Weather Station) data

PWSWatcher Why? PWSWatcher is an open-source Android app used to monitor a PWS (Personal Weather Station) given the link of its real-time updated .xml

Giorgio Bertolotti 17 Oct 13, 2022
LiveLine - A Health Monitoring/Awareness/Risk-Alert App which will display a Person's Heart rate, SpO2 level concentration and Body Temperature

A Health Monitoring/Awareness/Risk-Alert App which will display a Person's Heart rate, SpO2 (oxygen% in the body) level concentration and Body Temperature

Arpit Patawat 6 Jun 7, 2022
FlutterCardSwipe Card Swipe Animation Creating the swipe view as used in the Tinder.

FlutterCardSwipe Card Swipe Animation Creating the swipe view as used in the Tinder. Swipe right is considered accepted and swipe left is rejected.It

Ruchika Gupta 517 Dec 27, 2022