Take care of thumbnailes for images downloaded from the network
This commit is contained in:
parent
3c775028f9
commit
bce1d95839
1 changed files with 22 additions and 16 deletions
|
@ -1,3 +1,4 @@
|
|||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -33,22 +34,27 @@ class _ImageWidgetState extends State<ImageWidget> {
|
|||
if (cachedImage != null) {
|
||||
image = cachedImage;
|
||||
} else {
|
||||
image = FutureBuilder<Uint8List>(
|
||||
future:
|
||||
AssetEntity(id: widget.photo.localId).thumbDataWithSize(size, size),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
Image image = Image.memory(snapshot.data,
|
||||
width: size.toDouble(),
|
||||
height: size.toDouble(),
|
||||
fit: BoxFit.cover);
|
||||
ImageLruCache.setData(path, size, image);
|
||||
return image;
|
||||
} else {
|
||||
return loadWidget;
|
||||
}
|
||||
},
|
||||
);
|
||||
if (widget.photo.localId.isNotEmpty) {
|
||||
image = FutureBuilder<Uint8List>(
|
||||
future: AssetEntity(id: widget.photo.localId)
|
||||
.thumbDataWithSize(size, size),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
Image image = Image.memory(snapshot.data,
|
||||
width: size.toDouble(),
|
||||
height: size.toDouble(),
|
||||
fit: BoxFit.cover);
|
||||
ImageLruCache.setData(path, size, image);
|
||||
return image;
|
||||
} else {
|
||||
return loadWidget;
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
image = Image.file(File(widget.photo.localPath),
|
||||
width: size.toDouble(), height: size.toDouble(), fit: BoxFit.cover);
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
|
|
Loading…
Add table
Reference in a new issue