Skip to content

Commit

Permalink
🐛 Fix view assets with only selected
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Feb 4, 2024
1 parent 9a8c4c1 commit 7609453
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion example/lib/customs/pickers/insta_asset_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,12 @@ class InstaAssetPickerBuilder extends DefaultAssetPickerBuilderDelegate {
@override
Future<void> viewAsset(
BuildContext context,
int index,
int? index,
AssetEntity currentAsset,
) async {
if (index == null) {
return;
}
// if is preview asset, unselect it
if (provider.selectedAssets.isNotEmpty &&
_previewAsset.value == currentAsset) {
Expand Down
8 changes: 6 additions & 2 deletions lib/src/delegates/asset_picker_builder_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ class DefaultAssetPickerBuilderDelegate
@override
Future<void> viewAsset(
BuildContext context,
int index,
int? index,
AssetEntity currentAsset,
) async {
final DefaultAssetPickerProvider provider =
Expand Down Expand Up @@ -902,6 +902,10 @@ class DefaultAssetPickerBuilderDelegate
selected = provider.selectedAssets;
effectiveIndex = current.indexOf(currentAsset);
}
} else if (index == null) {
current = provider.selectedAssets;
selected = provider.selectedAssets;
effectiveIndex = selected.indexOf(currentAsset);
} else {
current = provider.currentAssets;
selected = provider.selectedAssets;
Expand Down Expand Up @@ -1936,7 +1940,7 @@ class DefaultAssetPickerBuilderDelegate
child: Consumer<DefaultAssetPickerProvider>(
builder: (context, DefaultAssetPickerProvider p, __) => GestureDetector(
onTap: p.isSelectedNotEmpty
? () => viewAsset(context, 0, p.selectedAssets.first)
? () => viewAsset(context, null, p.selectedAssets.first)
: null,
child: Selector<DefaultAssetPickerProvider, String>(
selector: (_, DefaultAssetPickerProvider p) =>
Expand Down

0 comments on commit 7609453

Please sign in to comment.