Skip to content

Commit 2649abd

Browse files
committed
v1.1.1
1 parent fc8c8cb commit 2649abd

File tree

6 files changed

+75
-25
lines changed

6 files changed

+75
-25
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@
3737

3838
## 1.1.0
3939
* added a `BlurhashTheImage` widget which takes an `ImageProvider` and gives out `ImageProvider` of the resulting blurry Image in one step.
40-
* also made it clear that `BlurhashFFI.free()` should be only run when you are sure there are no more blurhashes to be decoded/encoded in your app.
40+
* also made it clear that `BlurhashFFI.free()` should be only run when you are sure there are no more blurhashes to be decoded/encoded in your app.
41+
42+
## 1.1.1
43+
* modify readme.md to explain how to use `BlurhashTheImage` widget

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,34 @@ Matches the official [Blurhash](https://github.com/woltapp/blurhash) implementat
1111
## Usage
1212
To use this plugin, add `blurhash_ffi` as a dependency in your pubspec.yaml file
1313

14+
**One Step (both Encoding & Decoding) Usage**
15+
```dart
16+
import 'package:blurhash_ffi/blurhash_ffi.dart';
17+
18+
/// Encoding and Decoding all in One Step
19+
///
20+
/// `ImageProvider` in -> Send your Image to be encoded.
21+
/// `ImageProvider` out -> Get your blurry image version.
22+
23+
class BlurhashMyImage extends StatelessWidget {
24+
final String imageUrl;
25+
const BlurhashMyImage({required this.imageUrl, super.key});
26+
27+
@override
28+
Widget build(BuildContext context) {
29+
return Image(
30+
image: BlurhashTheImage(
31+
NetworkImage(imageUrl), // you can use any image provider of your choice.
32+
decodingHeight: 1920, decodingWidth: 1080),
33+
alignment: Alignment.center,
34+
fit: BoxFit.cover
35+
);
36+
}
37+
}
38+
39+
40+
```
41+
1442
**Encoding**
1543

1644
<?code-excerpt "readme_excerpts.dart (Example)"?>

example/lib/main.dart

+39-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:blurhash_ffi/blurhash_the_image.dart';
1+
import 'package:blurhash_ffi/blurhash_ffi.dart';
22
import 'package:flutter/material.dart';
33

44
void main() {
@@ -57,26 +57,28 @@ class _MyAppState extends State<MyApp> {
5757
Align(
5858
alignment: Alignment.center,
5959
child: SizedBox(
60-
height: 120,
61-
width: 120,
62-
child: Image(
63-
image: BlurhashTheImage(
64-
AssetImage(
65-
selectedImage == 2 ? 'assets/images/$selectedImage.png' :
66-
'assets/images/$selectedImage.jpg'),
67-
decodingWidth: 120,
68-
decodingHeight: 120,
69-
),
70-
loadingBuilder: (context, child, loadingProgress) => loadingProgress == null
71-
? child
72-
: const Center(
73-
child: CircularProgressIndicator(
74-
color: Color(0xFFF1D4D4),
75-
),
76-
),
77-
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) => child,
78-
)
79-
),
60+
height: 120,
61+
width: 120,
62+
child: Image(
63+
image: BlurhashTheImage(
64+
AssetImage(selectedImage == 2
65+
? 'assets/images/$selectedImage.png'
66+
: 'assets/images/$selectedImage.jpg'),
67+
decodingWidth: 120,
68+
decodingHeight: 120,
69+
),
70+
loadingBuilder: (context, child, loadingProgress) =>
71+
loadingProgress == null
72+
? child
73+
: const Center(
74+
child: CircularProgressIndicator(
75+
color: Color(0xFFF1D4D4),
76+
),
77+
),
78+
frameBuilder:
79+
(context, child, frame, wasSynchronouslyLoaded) =>
80+
child,
81+
)),
8082
)
8183
],
8284
),
@@ -110,3 +112,19 @@ class ImageSelect extends StatelessWidget {
110112
);
111113
}
112114
}
115+
116+
class BlurhashMyImage extends StatelessWidget {
117+
final String imageUrl;
118+
const BlurhashMyImage({required this.imageUrl, super.key});
119+
120+
@override
121+
Widget build(BuildContext context) {
122+
return Image(
123+
image: BlurhashTheImage(
124+
NetworkImage(imageUrl), // you can use any image provider of your choice.
125+
decodingHeight: 1920, decodingWidth: 1080),
126+
alignment: Alignment.center,
127+
fit: BoxFit.cover,
128+
);
129+
}
130+
}

example/pubspec.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ packages:
2323
path: ".."
2424
relative: true
2525
source: path
26-
version: "1.1.0"
26+
version: "1.1.1"
2727
boolean_selector:
2828
dependency: transitive
2929
description:

lib/blurhash_ffi.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ library blurhash_ffi;
33
export './blurhash.dart';
44
export './uiImage.dart';
55
export 'blurhashffi_image.dart';
6-
export 'blurhashffi_widget.dart';
6+
export 'blurhashffi_widget.dart';
7+
export 'blurhash_the_image.dart';

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: blurhash_ffi
22
description: >-
33
A compact, fast and easy to use blurry image placeholder generator for Flutter
44
using native ffi bindings.
5-
version: 1.1.0
5+
version: 1.1.1
66
repository: https://github.com/folksable/blurhash_ffi
77

88
environment:

0 commit comments

Comments
 (0)