easy_permission_validator 1.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 90

Easy Permission Validator #

This package is useful when you need to manage on-demand permissions for both Android and iOS.

pub package

Usage #

To use this plugin, add easy_permission_validator as a dependency in your pubspec.yaml file.

Base use:

_permissionRequest() async {
  final permissionValidator = EasyPermissionValidator(
    context: context,
    appName: 'Easy Permission Validator',
  );
  var result = await permissionValidator.camera();
  if (result) {
    // Do something;
  }
}

You can add custom messages for other languages:

_permissionRequest() async {
  final permissionValidator = EasyPermissionValidator(
    context: context,
    appName: 'Easy Permission Validator',
    appNameColor: Colors.red,
    cancelText: 'Cancelar',
    enableLocationMessage:
        'Debe habilitar los permisos necesarios para utilizar la acción.',
    goToSettingsText: 'Ir a Configuraciones',
    permissionSettingsMessage:
        'Necesita habilitar los permisos necesarios para que la aplicación funcione correctamente',
  );
  var result = await permissionValidator.camera();
  if (result) {
    // Do something;
  }
}

In addition, you can add a custom Dialog:

_permissionWithCustomPopup() async {
  final permissionValidator = EasyPermissionValidator(
    context: context,
    appName: 'Easy Permission Validator',
    customDialog: MyAmazingCustomPopup(),
  );
  var result = await permissionValidator.camera();
  if (result) {
    // Do something;
  }
}

Caution #

Some permissions must be in the privacy policy

Permissions #

If you use any permissions from this package, you must add:

For iOS (add in ios/Runner/Info.plist):

CALENDAR:
<key>NSCalendarsUsageDescription</key>
<string>This app requires calendars access to function properly.</string>

CAMERA:
<key>NSCameraUsageDescription</key>
<string>App requires access to the camera.</string>

CONTACTS:
<key>NSContactsUsageDescription</key>
<string>This app requires contacts access to function properly.</string>

LOCATION:
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app requires location access to function properly.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app requires location access to function properly.</string>
<key>NSLocationUsageDescription</key>
<string>This app requires location access to function properly.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app requires location access to function properly.</string>

MICROPHONE:
<key>NSMicrophoneUsageDescription</key>
<string>This app requires mic access to record video.</string>

PHOTOS:
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires photo library access to function properly.</string>

SENSORS:
<key>NSMotionUsageDescription</key>
<string>This app requires motion access</string>

REMINDER:
<key>NSRemindersUsageDescription</key>
<string>This app requires reminders access to function properly.</string>

MICROPHONE:
<key>NSSpeechRecognitionUsageDescription</key>
<string>This app requires mic access to record video.</string>

For ANDROID (add in android/app/src/main/AndroidManifest.xml):

Permissions on Android

LOCATION:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

CALENDAR:
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />

STORAGE:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

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

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

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

CONTACTS:
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

PHONE:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
<uses-permission android:name="android.permission.ADD_VOICEMAIL" />
<uses-permission android:name="android.permission.USE_SIP" />

SMS:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_WAP_PUSH" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />

Issues #

Please file any issues, bugs or feature request as an issue on our GitHub page.

Contributions #

You can contribute by making a pull request, this package was made for the community and you have complete power to add whatever they find useful.

1.0.6 #

  • Update last version of PermissionHandler package.
  • Fixed storage permission with iOS devices.

1.0.5 #

  • Fix the customDialog and the messages fields.
  • Add an extra example.

1.0.4 #

  • Add LICENSE.

1.0.3 #

  • Add more detail to the description field of pubspec.yaml.

1.0.2 #

  • Add Example.

1.0.1 #

  • Add README description.

1.0.0 #

  • Initial release.

example/README.md

example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  easy_permission_validator: ^1.0.6

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:easy_permission_validator/easy_permission_validator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
80
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
90
Learn more about scoring.

We analyzed this package on Oct 19, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
permission_handler ^3.2.0 3.3.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test