Precache image only if the widget is still mounted
This commit is contained in:
parent
bda0d8afd9
commit
1d2630ecb9
1 changed files with 13 additions and 11 deletions
|
@ -121,17 +121,19 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
|
|||
_isLoadingThumbnail = true;
|
||||
getThumbnailFromServer(widget.file).then((file) {
|
||||
final imageProvider = Image.file(file).image;
|
||||
precacheImage(imageProvider, context).then((value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_imageProvider = imageProvider;
|
||||
_hasLoadedThumbnail = true;
|
||||
});
|
||||
}
|
||||
}).catchError((e) {
|
||||
_logger.severe("Could not load image " + widget.file.toString());
|
||||
_encounteredErrorLoadingThumbnail = true;
|
||||
});
|
||||
if (mounted) {
|
||||
precacheImage(imageProvider, context).then((value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_imageProvider = imageProvider;
|
||||
_hasLoadedThumbnail = true;
|
||||
});
|
||||
}
|
||||
}).catchError((e) {
|
||||
_logger.severe("Could not load image " + widget.file.toString());
|
||||
_encounteredErrorLoadingThumbnail = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue