Skip to content

Commit

Permalink
🐛 Fix current asset in the picker viewer (fluttercandies#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 authored Mar 7, 2024
1 parent b714de7 commit 263db78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ that can be found in the LICENSE file. -->
## 9.0.1

### Fixes

- Fix current asset in the picker viewer.

### Improvements

- Improve code formatting.
Expand Down
11 changes: 9 additions & 2 deletions lib/src/delegates/asset_picker_viewer_builder_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ abstract class AssetPickerViewerBuilderDelegate<Asset, Path> {

/// Getter for the current asset.
/// 当前资源的Getter
Asset get currentAsset => previewAssets.elementAt(currentIndex);
Asset get currentAsset => previewAssets.elementAt(
shouldReversePreview
? previewAssets.length - currentIndex - 1
: currentIndex,
);

/// Height for bottom preview widget.
/// 底栏预览部件的高度
Expand Down Expand Up @@ -890,7 +894,10 @@ class DefaultAssetPickerViewerBuilderDelegate
initialData: currentIndex,
stream: pageStreamController.stream,
builder: (_, s) {
final AssetEntity asset = previewAssets.elementAt(s.data!);
final index = s.data!;
final AssetEntity asset = previewAssets.elementAt(
shouldReversePreview ? previewAssets.length - index - 1 : index,
);
return Selector<AssetPickerViewerProvider<AssetEntity>,
List<AssetEntity>>(
selector: (_, p) => p.currentlySelectedAssets,
Expand Down

0 comments on commit 263db78

Please sign in to comment.