Browse Source

权限设置,按钮状态异常修复;

wr_2023_new_business_new
wurong 5 months ago
parent
commit
3bad0d5501
  1. 28
      lib/setting/permission_setting_page.dart

28
lib/setting/permission_setting_page.dart

@ -15,14 +15,20 @@ class PermissionSettingPage extends StatefulWidget {
} }
} }
class _PermissionSettingPage extends State<PermissionSettingPage> { class _PermissionSettingPage extends State<PermissionSettingPage> with WidgetsBindingObserver {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addObserver(this);
queryPermission(); queryPermission();
} }
@override
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
}
List<String> title = [ List<String> title = [
S.current.dingwei, S.current.dingwei,
S.current.tongzhi, S.current.tongzhi,
@ -75,14 +81,24 @@ class _PermissionSettingPage extends State<PermissionSettingPage> {
]; ];
queryPermission() async { queryPermission() async {
await permissions.forEach((element) async { for(var it in permissions){
if (await element.isGranted) { if (await it.isGranted) {
permissionSwitch[element] = true; permissionSwitch[it] = true;
} }
}); }
setState(() {}); setState(() {});
} }
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
//
queryPermission();
} else if (state == AppLifecycleState.paused) {
//
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(

Loading…
Cancel
Save