flutter_blurhash 0.2.1 flutter_blurhash: ^0.2.1 copied to clipboard
Compact representation of a placeholder for an image. Encode a blurry image under 30 caracters for instant display like used by Medium
import 'package:flutter/material.dart';
import 'package:flutter_blurhash/flutter_blurhash.dart';
const entries = [
// see how $ should be escaped
[
'L8C6M\$9tcY,F00%2RPNaUawdv#K4',
'https://drivetribe.imgix.net/fvHsAWZPQVah0hivwdPPtw?w=1600&h=1067&fm=webp&auto=compress&lossless=true&fit=crop&crop=faces',
''
],
[
'L76RZIxv00IAj?WBayt700M{_4%g',
'https://drivetribe.imgix.net/G_Xtlr1RQXiEklCPX8auGw?w=2400&h=1350&fm=webp&auto=compress&lossless=true&fit=crop&crop=faces',
''
],
[
'LZG6p1{I^6rX}G=0jGR\$Z|t7NLW,',
'https://drivetribe.imgix.net/C8AqQLEWTMShpDF2QcABNQ?w=1600&h=1067&fm=webp&auto=compress&lossless=true&fit=crop&crop=faces',
''
],
[
'L371cr_3RKKFsqICIVNG00eR?d-r',
'https://drivetribe.imgix.net/R7OHpnZoRvSvE5rB9ZaGrw?w=2400&h=1350&fm=webp&auto=compress&lossless=true&fit=crop&crop=faces',
''
],
];
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false, home: const BlurHashApp()));
}
class BlurHashApp extends StatelessWidget {
const BlurHashApp({Key key}) : super(key: key);
void onDecoded() {
print("Decoded");
}
@override
Widget build(BuildContext context) => MaterialApp(
home: Center(
child: ConstrainedBox(
constraints: BoxConstraints.tight(const Size(500, 1250)),
child: ListView.builder(
itemCount: entries.length,
itemExtent: 300,
itemBuilder: (ctx, idx) => Container(
margin: const EdgeInsets.only(bottom: 4),
child: BlurHash(
fadeInDuration: const Duration(milliseconds: 1800),
onDecoded: onDecoded,
hash: entries[idx][0],
image: entries[idx][1]),
),
),
),
),
);
}