top of page
  • Manas Mohanty

Implementing Permission handling in Flutter

What is Permission handling?

Permission handling is features of Flutter apps where you ask different types of permission from users like speech recognition, internet, location, contacts to facilitate the process of app.

How to use permission handling in flutter

Step 1.

Mention the permission handler package in pubspec.yaml file(Config file of flutter)



Package name:Permission_handler:5.0.1+1

Once you declare the package. Get the package downloaded inside your app.

Using "Flutter pub get" (from your terminal or command)


Step-2

Import the permission handler package in your required page.


The highlighted text shows how to call the permission_handler package in your dart file.


Step 3

Bind the CheckSMSPermission function to required button or function which can call the permission handling feature on pressed.

Source code of CheckSMSPermission is mentioned in Source code figure.

Else statement is blank in CheckSMSPermission . You can customize the else statement.



Here my required button is raised button " ask permission"


Step 4

Mention the CheckSMS permission function outside your widget build.

Check your button or function where you have mentioned checkSMSPermission function

It will show you a pop-up screen with Allow and Deny option initially when pressed at button.

Then with an extra option Deny and don’t ask again when you Deny permission.





Reference



74 views0 comments

Recent Posts

See All
bottom of page