super_easy_permissions

A flutter plugin for handling permissions on Android/iOS in a very simple way.

On most operating systems, permissions aren't just granted to apps at install time. Rather, developers have to ask the user for permissions while the app is running. This plugin provides a cross-platform (iOS, Android) API to request permissions and check their status. You can also open the device's app settings so users can grant a permission.

How to use

Step 1:

First add this package in your pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
  super_easy_permissions: any

Make sure to GET all the pub packages after saving this file.

Step 2:

Android

Add the required permissions in your AndroidManifest.xml file:

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />

In this case, I have added camera permission (which also require adding hardware feature). Your's case may be different. For example, You may require storage permissions.

NOTE: If you need to add storage permissions in AndroidManifest.xml, make sure to add the following line in manifest file:

<application
      android:requestLegacyExternalStorage="true"
      ...

For a list of all permissions, visit Google Developers site.

iOS

Add required permissions in Info.plist file:

<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) camera description.</string>

In this case, I have added camera permission. Your need may be different. For a list of all permissions, visit Apple Developers site.

Step 3

Import the library in your dart file:

import 'package:super_easy_permissions/super_easy_permissions.dart';

Step 4

Finally, use the package

Check if permission is granted

bool result = await SuperEasyPermissions.isGranted(Permissions.Camera);
if (result) {
  // Permission is granted, do something
}

Ask for permission

bool result = await SuperEasyPermissions.askPermission(Permissions.Camera);
if (result) {
  // Permission is granted, do something
} else {
  // Permission denied, do something else
}

Check if permission is denied

bool result = await SuperEasyPermissions.isDenied(Permissions.Camera);
if (result) {
  // Permission is denied, do something
}

Check if permission is permanently denied

int result = await SuperEasyPermissions.isPermanentlyDenied(Permissions.Camera);
if (result) {
  // Permission is permanently denied, do something
}

Permissions Reference

Permissions.Internet    // For iOS only
Permissions.Calendar
Permissions.Camera
Permissions.Contacts
Permissions.Microphone
Permissions.Location
Permissions.WhenInUse   // For iOS only
Permissions.Phone       // For Android only
Permissions.Sensors     // For Android only
Permissions.SMS         // For Android only
Permissions.Storage     // For Android only
Permissions.State       // For Android only

Issues

Don't hesitate to email any issues or feature at riturajshakti@gmail.com.

Want to contribute

Please support me via Donation. Your donation seriously motivates me to develop more useful packages like this.

Author

This Permission plugin for Flutter is developed by Rituraj Shakti. You can contact me at riturajshakti@gmail.com

Libraries

super_easy_permissions