【发布时间】:2021-05-25 12:13:52
【问题描述】:
我一直在寻找这个,在我的程序中,我使用permission_handler 来启用相机权限。但是,我也希望我的用户能够以编程方式禁用相机权限。
代码如下:
child: SwitchListTile(
contentPadding: EdgeInsets.all(0),
value: isCameraAllowed,
onChanged: (value) async {
if(value){
var isGranted = await Permission.camera.request().isGranted;
if(isGranted){
setState(() {
isCameraAllowed = value;
});
}
}
},
title: Row(
children: [
Text(S.current.privacySettingsPageActiveDeactive),
Spacer(),
Icon(isCameraAllowed ? Icons.videocam : Icons.videocam_off)
],
),
)
我使用 SwichListTile 来指示权限是打开还是关闭,所以当用户将磁贴打开为 on 时,我可以请求权限并更新它当用户想要关闭权限时,我找不到办法。有人可以帮忙吗?
【问题讨论】:
标签: android flutter dart permissions