I have been searching for this for a while, in my program, I use permission_handler to enable camera permission. However, I also want my users to be able to disable the camera permissions programmatically.
Here is the code:
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)
],
),
)
I use SwichListTile to indicate either the permission is on or off, so when the user turns tile to on, I am able to ask for permission and update it however when the user wants to turn off the permission, I could not find a way to do it. Can anyone help with it?