Resolve object tags for local files as well

This commit is contained in:
vishnukvmd 2023-02-08 22:51:57 +05:30
parent e53581603c
commit fb0042ae03
2 changed files with 13 additions and 2 deletions

View file

@ -14,8 +14,8 @@ class ObjectTagsWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FutureBuilder<List<String>>(
future: getThumbnailFromServer(file).then((data) {
return ObjectDetectionService.instance.predict(data);
future: getThumbnail(file).then((data) {
return ObjectDetectionService.instance.predict(data!);
}),
builder: (context, snapshot) {
if (snapshot.hasData) {

View file

@ -32,6 +32,17 @@ class FileDownloadItem {
FileDownloadItem(this.file, this.completer, this.cancelToken, this.counter);
}
Future<Uint8List?> getThumbnail(File file) async {
if (file.isRemoteFile) {
return getThumbnailFromServer(file);
} else {
return getThumbnailFromLocal(
file,
size: thumbnailLargeSize,
);
}
}
Future<Uint8List> getThumbnailFromServer(File file) async {
final cachedThumbnail = cachedThumbnailPath(file);
if (await cachedThumbnail.exists()) {