I am trying to access the microphone of the users device, I have managed to integrate the permissions_handler package somewhat successfully. When I clicked the mic icon the request permission message popped up as expected but I pressed deny to deal with that scenario but now, when I click the mic icon no message pops up because I have already denied permission. My question is, how I can re-ask user for their permission if they haven't granted it before? Here is my code:
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
class InsideLeft extends StatefulWidget {
@override
_InsideLeftState createState() => _InsideLeftState();
}
class _InsideLeftState extends State<InsideLeft> {
@override
Widget build(BuildContext context) {
return Container(
child: GestureDetector(
child: Icon(Icons.mic),
onTap: () async {
var status = await Permission.microphone.status;
switch (status) {
case PermissionStatus.granted:
print('Granted');
break;
case PermissionStatus.denied:
print('denied');
await Permission.microphone.request();
break;
case PermissionStatus.restricted:
print('restricted');
break;
case PermissionStatus.undetermined:
print('undetermined');
break;
case PermissionStatus.permanentlyDenied:
print('Permanently denied');
break;
default:
}
},
),
);
}
}