Closed aytunch closed 2 years ago
I was experimenting and added widget.onDecoded?.call();
before Image
is being returned.
I don't know why but the future builder fires more than once. Maybe it is because the buildBlurHashBackground
is a widget function
rather than a StatelessWidget
. Same with prepareDisplayedImage
. Fixing this would increase performance for sure.
Another solution might be to use decoded
and decoding
bool
like the ones used in the code:
loaded = false;
loading = false;
And inside of the build method we can do
if(decoded)
return Image(image: UiImage(snap.data), fit: widget.imageFit);
Widget buildBlurHashBackground() => FutureBuilder<ui.Image>(
future: _image,
builder: (ctx, snap) {
if (snap.hasData) {
print("onDecoded hash:${widget.hash}");
widget.onDecoded?.call(); //This gets called for more than once per widget.
return Image(image: UiImage(snap.data), fit: widget.imageFit);
} else {
return Container(color: widget.color);
}
},
);
}
Hi, onDecoded and onDisplayed events have been added. Thx
We see
onDecoded
in the packages API however It is not connected to the related action at the moment. There is no instance ofcall(widget.onDecoded)
Could you please addonDecoded
on both the nullsafe and nullable versions.