-
Notifications
You must be signed in to change notification settings - Fork 56
/
permission_apply.dart
51 lines (49 loc) · 1.79 KB
/
permission_apply.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'package:flutter/material.dart';
import 'package:flutter_learn/utils/toast.dart';
import 'package:permission_handler/permission_handler.dart';
class PermissionApplyPage extends StatefulWidget {
final String title;
PermissionApplyPage(this.title, {Key key}) : super(key: key);
@override
_PermissionApplyPageState createState() => _PermissionApplyPageState();
}
class _PermissionApplyPageState extends State<PermissionApplyPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title), actions: <Widget>[
IconButton(
icon: const Icon(Icons.settings),
onPressed: () {
openAppSettings().then((bool hasOpened) =>
debugPrint('App Settings opened: ' + hasOpened.toString()));
},
)
]),
body: SingleChildScrollView(
padding: const EdgeInsets.all(10),
child: Column(children: <Widget>[
ButtonBar(
alignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RaisedButton(
child: Text('相机权限申请'),
onPressed: () {
Permission.camera
.request()
.then((value) => {XToast.toast("申请结果:$value")});
},
),
RaisedButton(
child: Text('相机权限检查'),
onPressed: () {
Permission.camera.status
.then((value) => {XToast.toast("检查结果:$value")});
},
),
],
)
])));
}
}