Skip to content

A flutter plugin for handling permissions on Android / iOS.

License

Notifications You must be signed in to change notification settings

bhavneet0812/SuperEasyPermission

 
 

Repository files navigation

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
}

Permissions Reference

  Permissions.accessMediaLocation        // for android only
  Permissions.activityRecognition        // for android only
  Permissions.bluetooth
  Permissions.calendar
  Permissions.camera
  Permissions.contacts
  Permissions.ignoreBatteryOptimizations // for ios only
  Permissions.location
  Permissions.locationAlways
  Permissions.locationWhenInUse
  Permissions.mediaLibrary               // for ios only
  Permissions.microphone
  Permissions.notification
  Permissions.phone                      // for android only
  Permissions.photos                     // for ios only
  Permissions.photosAddOnly              // for ios only
  Permissions.reminders                  // for ios only
  Permissions.sensors
  Permissions.sms                        // for android only
  Permissions.speech
  Permissions.storage

Issues

Don't hesitate to email any issues or feature at [email protected].

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 [email protected]

About

A flutter plugin for handling permissions on Android / iOS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 64.1%
  • Ruby 14.6%
  • Kotlin 10.1%
  • Swift 6.1%
  • Objective-C 5.1%