Remove unnecessary delay for loading thumbnail
This commit is contained in:
parent
5bd8b9b026
commit
ce86eb3bbb
1 changed files with 13 additions and 17 deletions
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue