blurhash 0.1.2 copy "blurhash: ^0.1.2" to clipboard
blurhash: ^0.1.2 copied to clipboard

outdated

A Flutter plugin for iOS and Android to decode a BlurHash string.

blurhash #

pub package

A Flutter plugin for iOS and Android to decode a BlurHash string.

Usage #

To use this plugin, add blurhash as a dependency in your pubspec.yaml file.

Example #

import 'dart:typed_data';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// Import package
import 'package:blurhash/blurhash.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Uint8List _imageDataBytes;

  @override
  void initState() {
    super.initState();
    blurHashDecode();
  }

  Future<void> blurHashDecode() async {
    Uint8List imageDataBytes;

    try {
      // Decodes a BlurHash string to bytes
      imageDataBytes = await BlurHash.decode("LBAdAqof00WCqZj[PDay0.WB}pof", 32, 32);
    } on PlatformException catch (e) {
      print(e.message);
    }

    if (!mounted) return;

    setState(() {
      _imageDataBytes = imageDataBytes;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('BlurHash example app'),
        ),
        body: Center(
          child: _imageDataBytes != null
              ? Image.memory(_imageDataBytes, width: 256, fit: BoxFit.cover)
              : Container(),
        ),
      ),
    );
  }
}
75
likes
0
pub points
89%
popularity

Publisher

verified publisherraincal.com

A Flutter plugin for iOS and Android to decode a BlurHash string.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on blurhash