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
95158f7a
Commit
95158f7a
authored
Feb 29, 2020
by
Maurits van Beusekom
Browse files
Options
Browse Files
Download
Plain Diff
Release 4.3.0
parents
d6d3621e
883cd349
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
lib/src/permission_enums.dart
+6
-6
lib/src/permission_handler.dart
+4
-4
lib/src/utils/codec.dart
+2
-2
No files found.
lib/src/permission_enums.dart
View file @
95158f7a
...
@@ -11,15 +11,15 @@ class PermissionStatus {
...
@@ -11,15 +11,15 @@ class PermissionStatus {
/// Permission to access the requested feature is granted by the user.
/// Permission to access the requested feature is granted by the user.
static
const
PermissionStatus
granted
=
PermissionStatus
.
_
(
1
);
static
const
PermissionStatus
granted
=
PermissionStatus
.
_
(
1
);
/// Permission to access the requested feature is denied by the OS (only on
/// Permission to access the requested feature is denied by the OS (only on
/// iOS). The user cannot change this app's status, possibly due to active
/// iOS). The user cannot change this app's status, possibly due to active
/// restrictions such as parental controls being in place.
/// restrictions such as parental controls being in place.
static
const
PermissionStatus
restricted
=
PermissionStatus
.
_
(
2
);
static
const
PermissionStatus
restricted
=
PermissionStatus
.
_
(
2
);
/// Permission is in an unknown state
/// Permission is in an unknown state
static
const
PermissionStatus
unknown
=
PermissionStatus
.
_
(
3
);
static
const
PermissionStatus
unknown
=
PermissionStatus
.
_
(
3
);
/// Permission to access the requested feature is denied by the user and
/// Permission to access the requested feature is denied by the user and
/// never show selected (only on Android).
/// never show selected (only on Android).
static
const
PermissionStatus
neverAskAgain
=
PermissionStatus
.
_
(
4
);
static
const
PermissionStatus
neverAskAgain
=
PermissionStatus
.
_
(
4
);
...
@@ -60,7 +60,7 @@ class ServiceStatus {
...
@@ -60,7 +60,7 @@ class ServiceStatus {
/// There is no service for the supplied permission group.
/// There is no service for the supplied permission group.
static
const
ServiceStatus
notApplicable
=
ServiceStatus
.
_
(
2
);
static
const
ServiceStatus
notApplicable
=
ServiceStatus
.
_
(
2
);
/// The unknown service status indicates the state of the service could not
/// The unknown service status indicates the state of the service could not
/// be determined.
/// be determined.
static
const
ServiceStatus
unknown
=
ServiceStatus
.
_
(
3
);
static
const
ServiceStatus
unknown
=
ServiceStatus
.
_
(
3
);
...
@@ -150,7 +150,7 @@ class PermissionGroup {
...
@@ -150,7 +150,7 @@ class PermissionGroup {
static
const
PermissionGroup
speech
=
PermissionGroup
.
_
(
13
);
static
const
PermissionGroup
speech
=
PermissionGroup
.
_
(
13
);
/// Android: External Storage
/// Android: External Storage
/// iOS: Access to folders like `Documents` or `Downloads`. Implicitly
/// iOS: Access to folders like `Documents` or `Downloads`. Implicitly
/// granted.
/// granted.
static
const
PermissionGroup
storage
=
PermissionGroup
.
_
(
14
);
static
const
PermissionGroup
storage
=
PermissionGroup
.
_
(
14
);
...
@@ -162,7 +162,7 @@ class PermissionGroup {
...
@@ -162,7 +162,7 @@ class PermissionGroup {
/// iOS: Notification
/// iOS: Notification
static
const
PermissionGroup
notification
=
PermissionGroup
.
_
(
16
);
static
const
PermissionGroup
notification
=
PermissionGroup
.
_
(
16
);
/// Android: Allows an application to access any geographic locations
/// Android: Allows an application to access any geographic locations
/// persisted in the user's shared collection.
/// persisted in the user's shared collection.
static
const
PermissionGroup
accessMediaLocation
=
PermissionGroup
.
_
(
17
);
static
const
PermissionGroup
accessMediaLocation
=
PermissionGroup
.
_
(
17
);
...
...
lib/src/permission_handler.dart
View file @
95158f7a
...
@@ -13,8 +13,8 @@ class PermissionHandler {
...
@@ -13,8 +13,8 @@ class PermissionHandler {
/// Constructs a singleton instance of [Geolocator].
/// Constructs a singleton instance of [Geolocator].
///
///
/// When a second instance is created, the first instance will not be able to
/// When a second instance is created, the first instance will not be able to
/// listen to the EventChannel because it is overridden. Forcing the class to
/// listen to the EventChannel because it is overridden. Forcing the class to
/// be a singleton class can prevent misuse of creating a second instance
/// be a singleton class can prevent misuse of creating a second instance
/// from a programmer.
/// from a programmer.
factory
PermissionHandler
()
{
factory
PermissionHandler
()
{
if
(
_instance
==
null
)
{
if
(
_instance
==
null
)
{
...
@@ -37,7 +37,7 @@ class PermissionHandler {
...
@@ -37,7 +37,7 @@ class PermissionHandler {
/// Check current permission status.
/// Check current permission status.
///
///
/// Returns a [Future] containing the current permission status for the
/// Returns a [Future] containing the current permission status for the
/// supplied [PermissionGroup].
/// supplied [PermissionGroup].
Future
<
PermissionStatus
>
checkPermissionStatus
(
Future
<
PermissionStatus
>
checkPermissionStatus
(
PermissionGroup
permission
)
async
{
PermissionGroup
permission
)
async
{
...
@@ -79,7 +79,7 @@ class PermissionHandler {
...
@@ -79,7 +79,7 @@ class PermissionHandler {
/// Open the App settings page.
/// Open the App settings page.
///
///
/// Returns [true] if the app settings page could be opened,
/// Returns [true] if the app settings page could be opened,
/// otherwise [false] is returned.
/// otherwise [false] is returned.
Future
<
bool
>
openAppSettings
()
async
{
Future
<
bool
>
openAppSettings
()
async
{
final
hasOpened
=
await
_methodChannel
.
invokeMethod
(
'openAppSettings'
);
final
hasOpened
=
await
_methodChannel
.
invokeMethod
(
'openAppSettings'
);
...
...
lib/src/utils/codec.dart
View file @
95158f7a
...
@@ -13,7 +13,7 @@ class Codec {
...
@@ -13,7 +13,7 @@ class Codec {
return
ServiceStatus
.
values
[
value
];
return
ServiceStatus
.
values
[
value
];
}
}
/// Converts the supplied [Map] of integers into a [Map] of
/// Converts the supplied [Map] of integers into a [Map] of
/// [PermissionGroup] key and [PermissionStatus] value instances.
/// [PermissionGroup] key and [PermissionStatus] value instances.
static
Map
<
PermissionGroup
,
PermissionStatus
>
decodePermissionRequestResult
(
static
Map
<
PermissionGroup
,
PermissionStatus
>
decodePermissionRequestResult
(
Map
<
int
,
int
>
value
)
{
Map
<
int
,
int
>
value
)
{
...
@@ -23,7 +23,7 @@ class Codec {
...
@@ -23,7 +23,7 @@ class Codec {
}
}
/// Converts the supplied [List] containing [PermissionGroup] instances into
/// Converts the supplied [List] containing [PermissionGroup] instances into
/// a [List] containing integers which can be used to send on the Flutter
/// a [List] containing integers which can be used to send on the Flutter
/// method channel.
/// method channel.
static
List
<
int
>
encodePermissionGroups
(
List
<
PermissionGroup
>
permissions
)
{
static
List
<
int
>
encodePermissionGroups
(
List
<
PermissionGroup
>
permissions
)
{
return
permissions
.
map
((
it
)
=>
it
.
value
).
toList
();
return
permissions
.
map
((
it
)
=>
it
.
value
).
toList
();
...
...
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