Skip to content

Commit 7faa9b5

Browse files
committed
🚑️ Fix potentially "No elements" error with thumbnails
1 parent a74c529 commit 7faa9b5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/src/provider/asset_picker_provider.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,14 @@ class DefaultAssetPickerProvider
384384
return true;
385385
}(),
386386
);
387-
final AssetEntity asset =
388-
(await path.getAssetListRange(start: 0, end: 1)).single;
387+
final List<AssetEntity> assets = await path.getAssetListRange(
388+
start: 0,
389+
end: 1,
390+
);
391+
if (assets.isEmpty) {
392+
return null;
393+
}
394+
final AssetEntity asset = assets.single;
389395
final Uint8List? assetData = await asset.thumbnailDataWithSize(
390396
pathThumbnailSize,
391397
);

0 commit comments

Comments
 (0)