Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
077b908e
Commit
077b908e
authored
Mar 17, 2021
by
Jan-Derk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated permission_handler
parent
aa9064a6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
permission_handler/lib/permission_handler.dart
+3
-3
permission_handler/test/permission_handler_test.dart
+21
-5
No files found.
permission_handler/lib/permission_handler.dart
View file @
077b908e
import
'
dart:io
'
;
import
'
package:flutter/cupertino.dart
'
;
import
'package:flutter/foundation.dart'
;
import
'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'
;
import
'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'
;
export
'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'
export
'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'
...
@@ -34,7 +34,7 @@ extension PermissionActions on Permission {
...
@@ -34,7 +34,7 @@ extension PermissionActions on Permission {
/// This is only implemented on Android, calling this on iOS always returns
/// This is only implemented on Android, calling this on iOS always returns
/// [false].
/// [false].
Future
<
bool
>
get
shouldShowRequestRationale
async
{
Future
<
bool
>
get
shouldShowRequestRationale
async
{
if
(
!
Platform
.
isA
ndroid
)
{
if
(
defaultTargetPlatform
!=
TargetPlatform
.
a
ndroid
)
{
return
false
;
return
false
;
}
}
...
...
permission_handler/test/permission_handler_test.dart
View file @
077b908e
...
@@ -22,12 +22,21 @@ void main() {
...
@@ -22,12 +22,21 @@ void main() {
expect
(
permissionStatus
,
PermissionStatus
.
granted
);
expect
(
permissionStatus
,
PermissionStatus
.
granted
);
});
});
test
(
'PermissionActions on Permission: get shouldShowRequestRationale'
,
test
(
// ignore: lines_longer_than_80_chars
'PermissionActions on Permission: get shouldShowRequestRationale should return true when on android'
,
()
async
{
()
async
{
final
requestRationale
=
final
mockPermissionHandlerPlatform
=
PermissionHandlerPlatform
.
instance
;
when
(
mockPermissionHandlerPlatform
.
shouldShowRequestPermissionRationale
(
Permission
.
calendar
))
.
thenAnswer
((
_
)
=>
Future
.
value
(
true
));
await
Permission
.
calendar
.
shouldShowRequestRationale
;
await
Permission
.
calendar
.
shouldShowRequestRationale
;
expect
(
requestRationale
,
false
);
verify
(
mockPermissionHandlerPlatform
.
shouldShowRequestPermissionRationale
(
Permission
.
calendar
))
.
called
(
1
);
});
});
test
(
'PermissionActions on Permission: request()'
,
()
async
{
test
(
'PermissionActions on Permission: request()'
,
()
async
{
...
@@ -108,6 +117,13 @@ class MockPermissionHandlerPlatform extends Mock
...
@@ -108,6 +117,13 @@ class MockPermissionHandlerPlatform extends Mock
}
}
@override
@override
Future
<
bool
>
shouldShowRequestPermissionRationale
(
Permission
permission
)
=>
Future
<
bool
>
shouldShowRequestPermissionRationale
(
Permission
?
permission
)
{
Future
.
value
(
true
);
return
super
.
noSuchMethod
(
Invocation
.
method
(
#shouldShowPermissionRationale
,
[
permission
],
),
returnValue:
Future
.
value
(
true
),
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment