asking for microphone permissions for android

2,589

So I used permission_handler

I just create a Future like this:

  Future askForPermissions() async {
        Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler().requestPermissions([PermissionGroup.microphone]);
}

and then on click of a IconButton called that it's working fine,

Share:
2,589
key
Author by

key

Currently working as a dart, Flutter Developer.

Updated on December 12, 2022

Comments

  • key
    key over 1 year

    I added a text-to-speech searcher for my app, so I can filter a list with speech, It works all fine the only thing is I have to accept the permissions manually from the permissions options tab of the app.

    I'm using the speech_recognition package for it.

    also in the android.Manifest.xml file at app>src>main I've added this

    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    In the console I get this error if I do not accept the permissions manually

    I/flutter (12585): _platformCallHandler call speech.onSpeechAvailability false

    I/flutter (12585): _platformCallHandler call speech.onError 9

    I/flutter (12585): Unknowm method speech.onError

    is there any other way so the system asks me to accept it when I for example click the speech icon?