File tree 5 files changed +36
-3
lines changed
5 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ that can be found in the LICENSE file. -->
9
9
### Improvements
10
10
11
11
- Improve assets change notify with better methods signature and checks. (#790 )
12
+ - Add ` PermissionState.hasAccess ` getter for better condition judgement. (#792 )
12
13
13
14
### Fixes
14
15
Original file line number Diff line number Diff line change @@ -59,12 +59,12 @@ class _SimpleExamplePageState extends State<_SimpleExamplePage> {
59
59
if (! mounted) {
60
60
return ;
61
61
}
62
- // Further requests can be only procceed with authorized or limited.
63
- if (ps != PermissionState .authorized && ps != PermissionState .limited ) {
62
+ // Further requests can be only proceed with authorized or limited.
63
+ if (! ps.hasAccess ) {
64
64
setState (() {
65
65
_isLoading = false ;
66
66
});
67
- showToast ('Permission is not granted .' );
67
+ showToast ('Permission is not accessible .' );
68
68
return ;
69
69
}
70
70
// Obtain assets using the path entity.
Original file line number Diff line number Diff line change @@ -9,4 +9,10 @@ extension PermissionStateExt on PermissionState {
9
9
bool get isAuth {
10
10
return this == PermissionState .authorized;
11
11
}
12
+
13
+ /// Whether the permission can access assets partially or fully,
14
+ bool get hasAccess {
15
+ return this == PermissionState .authorized ||
16
+ this == PermissionState .limited;
17
+ }
12
18
}
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 The FlutterCandies author. All rights reserved.
2
+ // Use of this source code is governed by an Apache license that can be found
3
+ // in the LICENSE file.
4
+
5
+ import 'package:flutter_test/flutter_test.dart' ;
6
+ import 'package:photo_manager/photo_manager.dart' ;
7
+
8
+ void main () {
9
+ test ('Permission extensions equality test' , () async {
10
+ const PermissionState permission = PermissionState .limited;
11
+ expect (
12
+ permission.isAuth == (permission == PermissionState .authorized),
13
+ equals (true ),
14
+ );
15
+ expect (
16
+ permission.hasAccess ==
17
+ (permission == PermissionState .authorized ||
18
+ permission == PermissionState .limited),
19
+ equals (true ),
20
+ );
21
+ });
22
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 The FlutterCandies author. All rights reserved.
2
+ // Use of this source code is governed by an Apache license that can be found
3
+ // in the LICENSE file.
4
+
1
5
// ignore_for_file: use_named_constants
2
6
import 'package:flutter_test/flutter_test.dart' ;
3
7
import 'package:photo_manager/photo_manager.dart' ;
You can’t perform that action at this time.
0 commit comments