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

Loading…
Cancel
Save