Remove unnecessary delay for loading thumbnail

This commit is contained in:
Vishnu Mohandas 2020-05-04 19:50:19 +05:30
parent 5bd8b9b026
commit ce86eb3bbb

View file

@ -39,30 +39,26 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
}
});
} else {
Future.delayed(Duration(milliseconds: 1000), () {
widget.photo
.getAsset()
.thumbDataWithSize(THUMBNAIL_SMALL_SIZE, THUMBNAIL_SMALL_SIZE)
.then((data) {
if (mounted) {
widget.photo
.getAsset()
.thumbDataWithSize(THUMBNAIL_SMALL_SIZE, THUMBNAIL_SMALL_SIZE)
.then((data) {
if (mounted) {
setState(() {
if (data != null) {
final imageProvider = Image.memory(data).image;
precacheImage(imageProvider, context).then((value) {
if (mounted) {
setState(() {
_imageProvider = imageProvider;
_hasLoadedThumbnail = true;
});
}
setState(() {
if (data != null) {
final imageProvider = Image.memory(data).image;
precacheImage(imageProvider, context).then((value) {
if (mounted) {
setState(() {
_imageProvider = imageProvider;
_hasLoadedThumbnail = true;
});
}
});
}
ThumbnailLruCache.put(widget.photo, THUMBNAIL_SMALL_SIZE, data);
});
}
ThumbnailLruCache.put(widget.photo, THUMBNAIL_SMALL_SIZE, data);
});
}
}