location_permissions 2.0.1 location_permissions: ^2.0.1 copied to clipboard
Location permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to check and request access to the location services on the device.
Flutter Location Permissions Plugin #
The Location Permissions plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to check and request permissions to access location services.
Branch | Build Status |
---|---|
develop | |
master |
Features #
- Check if permission to access location services is granted.
- Request permission to access location services.
- Open app settings so the user can allow permission to the location services.
- Show a rationale for requesting permission to access location services (Android).
Usage #
To use this plugin, add location_permissions
as a dependency in your pubspec.yaml file. For example:
dependencies:
location_permissions: '^2.0.0'
API #
Requesting permission #
import 'package:location_permissions/location_permissions.dart';
PermissionStatus permission = await LocationPermissions().requestPermissions();
Checking permission #
import 'package:location_permissions/location_permissions.dart';
PermissionStatus permission = await LocationPermissions().checkPermissionStatus();
Checking service status #
import 'package:location_permissions/location_permissions.dart';
ServiceStatus serviceStatus = await LocationPermissions().checkServiceStatus();
Open app settings #
import 'package:location_permissions/location_permissions.dart';
bool isOpened = await LocationPermissions().openAppSettings();
Show a rationale for requesting permission (Android only) #
import 'package:location_permissions/location_permissions.dart';
bool isShown = await LocationPermissions().shouldShowRequestPermissionRationale();
This will always return false
on iOS.
List of available permissions levels (only applicable for iOS) #
Defines the location permission levels for which can be used on iOS to distinguish between permission to access location services when the app is in use or always.
enum LocationPermissionLevel {
/// Android: Fine and Coarse Location
/// iOS: CoreLocation (Always and WhenInUse)
location,
/// Android: Fine and Coarse Location
/// iOS: CoreLocation - Always
locationAlways,
/// Android: Fine and Coarse Location
/// iOS: CoreLocation - WhenInUse
locationWhenInUse,
}
Status of the permission #
Defines the state of a location permissions
enum PermissionStatus {
/// Permission to access the location services is denied by the user.
denied,
/// Permission to access the location services is granted by the user.
granted,
/// The user granted restricted access to the location services (only on iOS).
restricted,
/// Permission is in an unknown state
unknown
}
Overview of possible service statuses #
Defines the state of the location services on the platform
/// Defines the state of the location services
enum ServiceStatus {
/// The unknown service status indicates the state of the location services could not be determined.
unknown,
/// Location services are not available on the device.
notApplicable,
/// The location services are disabled.
disabled,
/// The location services are enabled.
enabled
}
Issues #
Please file any issues, bugs or feature request as an issue on our GitHub page.
Want to contribute #
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.
Author #
This Permission handler plugin for Flutter is developed by Baseflow. You can contact us at hello@baseflow.com