Plugin for permission managment on runtime.
1. Depend on it Add this to your package's pubspec.yaml file:
dependencies:
permissions_plugin: ^1.1.4
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:permissions_plugin/permissions_plugin.dart';
- Request ignore battery optimization
- check status ignore battery optimization
You can also:
- Request permission on runtime
- Check status permission on runtime
import 'package:permissions_plugin/permissions_plugin.dart';
Map<Permission, PermissionState> permission = await PermissionsPlugin
.requestPermissions([
Permission.ACCESS_FINE_LOCATION,
Permission.ACCESS_COARSE_LOCATION,
Permission.READ_PHONE_STATE
]);
import 'package:permissions_plugin/permissions_plugin.dart';
Map<Permission, PermissionState> permission = await PermissionsPlugin
.checkPermissions([
Permission.ACCESS_FINE_LOCATION,
Permission.ACCESS_COARSE_LOCATION,
Permission.READ_PHONE_STATE
]);
import 'package:permissions_plugin/permissions_plugin.dart';
final PermissionState resBattery = await PermissionsPlugin
.requestIgnoreBatteryOptimization;
import 'package:permissions_plugin/permissions_plugin.dart';
final PermissionState status = await PermissionsPlugin
.isIgnoreBatteryOptimization;
Current suport Android only
enum Permission {
READ_CALENDAR,
WRITE_CALENDAR,
READ_CALL_LOG,
WRITE_CALL_LOG,
PROCESS_OUTGOING_CALLS,
CAMERA,
READ_CONTACTS,
WRITE_CONTACTS,
GET_ACCOUNTS,
ACCESS_FINE_LOCATION,
ACCESS_COARSE_LOCATION,
RECORD_AUDIO,
READ_PHONE_STATE,
CALL_PHONE,
ADD_VOICEMAIL,
USE_SIP,
BODY_SENSORS,
SEND_SMS,
RECEIVE_SMS,
READ_SMS,
RECEIVE_WAP_PUSH,
RECEIVE_MMS,
READ_EXTERNAL_STORAGE,
WRITE_EXTERNAL_STORAGE
}
enum PermissionState {
GRANTED,
DENIED,
UNKNOWN
}
### Platform Support
OS | Min Version |
---|---|
Android | minSdkVersion 16 |
IOS | soon |
MIT
This plugin is developed, Free Software, by Kevin Caicedo