blurHashDecodeImage function
Implementation
Future<ui.Image> blurHashDecodeImage({
required String blurHash,
required int width,
required int height,
double punch = 1.0,
}) async {
_validateBlurHash(blurHash);
final completer = Completer<ui.Image>();
if (kIsWeb) {
// https://github.com/flutter/flutter/issues/45190
final pixels = await blurHashDecode(
blurHash: blurHash, width: width, height: height, punch: punch);
completer.complete(_createBmp(pixels, width, height));
} else {
blurHashDecode(
blurHash: blurHash, width: width, height: height, punch: punch)
.then((pixels) {
ui.decodeImageFromPixels(
pixels, width, height, ui.PixelFormat.rgba8888, completer.complete);
});
}
return completer.future;
}