Skip to content

Commit af12849

Browse files
authored
🚀 Add index param in AssetPickerBuilderDelegate.selectAsset (#399)
This PR expose grid `index` param in the `selectAsset` delegate function.
1 parent 678ffc7 commit af12849

File tree

6 files changed

+42
-6
lines changed

6 files changed

+42
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ that can be found in the LICENSE file. -->
44

55
# Changelog
66

7+
## 8.3.0
8+
9+
### New features
10+
11+
- Add `index` argument to `selectAsset` in the `AssetPickerBuilderDelegate`. (#399)
12+
713
## 8.2.0
814

915
### New features

example/lib/customs/pickers/directory_file_asset_picker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ class FileAssetPickerBuilder
459459
}
460460

461461
@override
462-
void selectAsset(BuildContext context, File asset, bool selected) {
462+
void selectAsset(BuildContext context, File asset, int index, bool selected) {
463463
if (selected) {
464464
provider.unSelectAsset(asset);
465465
} else {

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wechat_assets_picker_demo
22
description: The demo project for the wechat_assets_picker package.
3-
version: 8.2.0+30
3+
version: 8.3.0+31
44
publish_to: none
55

66
environment:

guides/migration_guide.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,35 @@ This document gathered all breaking changes and migrations requirement between m
1414
- [6.0.0](#600)
1515
- [5.0.0](#500)
1616

17+
## 8.3.0
18+
19+
### Summary
20+
21+
Delegates extending `AssetPickerBuilderDelegate` that implements `selectAsset` should add the `index` argument to its signature.
22+
23+
### Details
24+
25+
Before:
26+
27+
```dart
28+
void selectAsset(
29+
BuildContext context,
30+
Asset asset,
31+
bool selected,
32+
);
33+
```
34+
35+
After:
36+
37+
```dart
38+
void selectAsset(
39+
BuildContext context,
40+
Asset asset,
41+
int index,
42+
bool selected,
43+
);
44+
```
45+
1746
## 8.2.0
1847

1948
### Summary

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
226226
/// to involve with predications, callbacks, etc.
227227
/// 选择资源的方法。自定义的 delegate 可以通过实现该方法,整合判断、回调等操作。
228228
@protected
229-
void selectAsset(BuildContext context, Asset asset, bool selected);
229+
void selectAsset(BuildContext context, Asset asset, int index, bool selected);
230230

231231
/// Called when assets changed and obtained notifications from the OS.
232232
/// 系统发出资源变更的通知时调用的方法
@@ -770,6 +770,7 @@ class DefaultAssetPickerBuilderDelegate
770770
Future<void> selectAsset(
771771
BuildContext context,
772772
AssetEntity asset,
773+
int index,
773774
bool selected,
774775
) async {
775776
final bool? selectPredicateResult = await selectPredicate?.call(
@@ -1344,7 +1345,7 @@ class DefaultAssetPickerBuilderDelegate
13441345
hint: hint,
13451346
image: asset.type == AssetType.image ||
13461347
asset.type == AssetType.video,
1347-
onTap: () => selectAsset(context, asset, isSelected),
1348+
onTap: () => selectAsset(context, asset, index, isSelected),
13481349
onTapHint: semanticsTextDelegate.sActionSelectHint,
13491350
onLongPress: isPreviewEnabled
13501351
? () => viewAsset(context, index, asset)
@@ -2036,7 +2037,7 @@ class DefaultAssetPickerBuilderDelegate
20362037
);
20372038
final Widget selectorWidget = GestureDetector(
20382039
behavior: HitTestBehavior.opaque,
2039-
onTap: () => selectAsset(context, asset, selected),
2040+
onTap: () => selectAsset(context, asset, index, selected),
20402041
child: Container(
20412042
margin: EdgeInsets.all(indicatorSize / 4),
20422043
width: isPreviewEnabled ? indicatorSize : null,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: |
33
An audio/video/image picker in pure Dart which is the same with WeChat,
44
support multi picking, custom item and delegates override.
55
repository: https://github.com/fluttercandies/flutter_wechat_assets_picker
6-
version: 8.2.0
6+
version: 8.3.0
77

88
environment:
99
sdk: '>=2.17.0 <3.0.0'

0 commit comments

Comments
 (0)