Skip to content

Commit da98755

Browse files
authored
🐛 Fix invalid path sort (#364)
1 parent 1c98ad5 commit da98755

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
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.0.4
8+
9+
### Fixes
10+
11+
- Fix invalid path sort. (#364)
12+
713
## 8.0.3
814

915
### Improvements

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.0.3+24
3+
version: 8.0.4+25
44
publish_to: none
55

66
environment:

lib/src/delegates/sort_path_delegate.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class CommonSortPathDelegate extends SortPathDelegate<AssetPathEntity> {
5454
if (a.path.isAll) {
5555
return -1;
5656
}
57-
if (a.path.isAll) {
57+
if (b.path.isAll) {
5858
return 1;
5959
}
6060
if (_isCamera(a.path)) {

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: 8.0.3
3+
version: 8.0.4
44
homepage: https://github.com/fluttercandies/flutter_wechat_assets_picker
55

66
environment:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// [Author] Alex (https://github.com/AlexV525)
3+
// [Date] 2022/9/19 11:52
4+
//
5+
6+
import 'package:flutter_test/flutter_test.dart';
7+
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
8+
9+
void main() {
10+
test('Sort paths correctly', () {
11+
final List<PathWrapper<AssetPathEntity>> paths =
12+
<PathWrapper<AssetPathEntity>>[
13+
PathWrapper<AssetPathEntity>(
14+
path: AssetPathEntity(id: 'id2', name: 'Screenshots'),
15+
),
16+
PathWrapper<AssetPathEntity>(
17+
path: AssetPathEntity(id: 'id1', name: 'Camera'),
18+
),
19+
PathWrapper<AssetPathEntity>(
20+
path: AssetPathEntity(id: 'id0', name: 'All', isAll: true),
21+
),
22+
];
23+
SortPathDelegate.common.sort(paths);
24+
expect(paths[0], (PathWrapper<AssetPathEntity> e) => e.path.isAll);
25+
expect(
26+
paths[1],
27+
(PathWrapper<AssetPathEntity> e) => e.path.name == 'Camera',
28+
);
29+
expect(
30+
paths[2],
31+
(PathWrapper<AssetPathEntity> e) => e.path.name == 'Screenshots',
32+
);
33+
});
34+
}

0 commit comments

Comments
 (0)