Skip to content

Commit 9cc7971

Browse files
committed
Merge branch 'master' into 6.0
# Conflicts: # pubspec.yaml
2 parents 724fa95 + d683fcf commit 9cc7971

File tree

6 files changed

+50
-3
lines changed

6 files changed

+50
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 5.5.7
8+
9+
- Make `switchPath` method in `AssetPickerProvider` async.
10+
711
## 5.5.6
812

913
- Add Japanese language text delegate. (Thanks to @KosukeSaigusa)

example/lib/constants/picker_method.dart

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,47 @@ class PickMethod {
9999
);
100100
}
101101

102+
factory PickMethod.cameraAndStay({required int maxAssetsCount}) {
103+
return PickMethod(
104+
icon: '📸',
105+
name: 'Pick from camera and stay',
106+
description: 'Take a photo or video with the camera picker, '
107+
'select the result and stay in the entities list.',
108+
method: (BuildContext context, List<AssetEntity> assets) {
109+
return AssetPicker.pickAssets(
110+
context,
111+
maxAssets: maxAssetsCount,
112+
selectedAssets: assets,
113+
requestType: RequestType.common,
114+
specialItemPosition: SpecialItemPosition.prepend,
115+
specialItemBuilder: (BuildContext context) {
116+
return GestureDetector(
117+
behavior: HitTestBehavior.opaque,
118+
onTap: () async {
119+
final AssetEntity? result = await CameraPicker.pickFromCamera(
120+
context,
121+
enableRecording: true,
122+
);
123+
if (result != null) {
124+
final AssetPicker<AssetEntity, AssetPathEntity> picker =
125+
context.findAncestorWidgetOfExactType()!;
126+
final DefaultAssetPickerProvider p =
127+
picker.builder.provider as DefaultAssetPickerProvider;
128+
await p.currentPathEntity!.refreshPathProperties();
129+
await p.switchPath(p.currentPathEntity!);
130+
p.selectAsset(result);
131+
}
132+
},
133+
child: const Center(
134+
child: Icon(Icons.camera_enhance, size: 42.0),
135+
),
136+
);
137+
},
138+
);
139+
},
140+
);
141+
}
142+
102143
factory PickMethod.common(int maxAssetsCount) {
103144
return PickMethod(
104145
icon: '📹',

example/lib/pages/multi_assets_page.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class _MultiAssetsPageState extends State<MultiAssetsPage>
3737
handleResult: (BuildContext context, AssetEntity result) =>
3838
Navigator.of(context).pop(<AssetEntity>[...assets, result]),
3939
),
40+
PickMethod.cameraAndStay(maxAssetsCount: maxAssetsCount),
4041
PickMethod.common(maxAssetsCount),
4142
PickMethod.threeItemsGrid(maxAssetsCount),
4243
PickMethod.customFilterOptions(maxAssetsCount),

example/lib/pages/single_assets_page.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class _SingleAssetPageState extends State<SingleAssetPage>
3737
handleResult: (BuildContext context, AssetEntity result) =>
3838
Navigator.of(context).pop(<AssetEntity>[result]),
3939
),
40+
PickMethod.cameraAndStay(maxAssetsCount: maxAssetsCount),
4041
PickMethod.common(maxAssetsCount),
4142
PickMethod.threeItemsGrid(maxAssetsCount),
4243
PickMethod.customFilterOptions(maxAssetsCount),

lib/src/provider/asset_picker_provider.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,12 @@ class DefaultAssetPickerProvider
366366
}
367367

368368
@override
369-
void switchPath(AssetPathEntity pathEntity) {
369+
Future<void> switchPath(AssetPathEntity pathEntity) async {
370370
_isSwitchingPath = false;
371371
_currentPathEntity = pathEntity;
372372
_totalAssetsCount = pathEntity.assetCount;
373373
notifyListeners();
374-
getAssetsFromEntity(0, currentPathEntity!);
374+
await getAssetsFromEntity(0, currentPathEntity!);
375375
}
376376

377377
@override

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
22
description: An audio/video/image picker in pure Dart which is the same with WeChat, support multi picking.
3-
version: 5.5.6
3+
version: 5.5.7
44
homepage: https://github.com/fluttercandies/flutter_wechat_assets_picker
55

66
environment:

0 commit comments

Comments
 (0)