|
|
@ -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( |
|
|
|