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
b3439372
Commit
b3439372
authored
Jul 23, 2018
by
Maurits van Beusekom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update example application
parent
d69d5a2b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
+14
-1
example/lib/main.dart
+14
-1
No files found.
example/lib/main.dart
View file @
b3439372
...
@@ -24,16 +24,21 @@ class _MyAppState extends State<MyApp> {
...
@@ -24,16 +24,21 @@ class _MyAppState extends State<MyApp> {
// Platform messages are asynchronous, so we initialize in an async method.
// Platform messages are asynchronous, so we initialize in an async method.
Future
<
void
>
initPlatformState
()
async
{
Future
<
void
>
initPlatformState
()
async
{
PermissionStatus
permissionStatus
;
PermissionStatus
permissionStatus
;
// Platform messages may fail, so we use a try/catch PlatformException.
// Platform messages may fail, so we use a try/catch PlatformException.
try
{
try
{
permissionStatus
=
await
PermissionHandler
.
checkPermissionStatus
(
PermissionGroup
.
calendar
);
permissionStatus
=
await
PermissionHandler
.
checkPermissionStatus
(
PermissionGroup
.
calendar
);
if
(
permissionStatus
!=
PermissionStatus
.
granted
){
if
(
permissionStatus
!=
PermissionStatus
.
granted
){
final
shouldShowRationale
=
await
PermissionHandler
.
shouldShowRequestPermissionRationale
(
PermissionGroup
.
calendar
);
if
(
shouldShowRationale
)
{
var
permissions
=
await
PermissionHandler
.
requestPermissions
([
PermissionGroup
.
calendar
]);
var
permissions
=
await
PermissionHandler
.
requestPermissions
([
PermissionGroup
.
calendar
]);
if
(
permissions
.
containsKey
(
PermissionGroup
.
calendar
))
{
if
(
permissions
.
containsKey
(
PermissionGroup
.
calendar
))
{
permissionStatus
=
permissions
[
PermissionGroup
.
calendar
];
permissionStatus
=
permissions
[
PermissionGroup
.
calendar
];
}
}
}
}
}
}
on
PlatformException
{
}
on
PlatformException
{
permissionStatus
=
PermissionStatus
.
unknown
;
permissionStatus
=
PermissionStatus
.
unknown
;
}
}
...
@@ -56,7 +61,15 @@ class _MyAppState extends State<MyApp> {
...
@@ -56,7 +61,15 @@ class _MyAppState extends State<MyApp> {
title:
const
Text
(
'Plugin example app'
),
title:
const
Text
(
'Plugin example app'
),
),
),
body:
new
Center
(
body:
new
Center
(
child:
new
Text
(
'Running on:
$_permissionStatus
\n
'
),
child:
new
Column
(
children:
<
Widget
>[
new
Text
(
'Running on:
$_permissionStatus
\n
'
),
new
RaisedButton
(
child:
new
Text
(
"Open settings"
),
onPressed:
()
async
=>
await
PermissionHandler
.
openAppSettings
(),
),
],
),
),
),
),
),
);
);
...
...
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