location_permissions 4.0.1
location_permissions: ^4.0.1 copied to clipboard

discontinued

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 #


Deprecation Notice #

This plugin has been replaced by the permission_handler. No further updates are planned to this plugin, and we encourage all users to migrate to the permission_handler.

This plugin was initially created to support the geolocator plugin and as a workaround for the issue #26 of the permission_handler plugin. However since version 5.0.0 of the permission_handler issue #26 has been resolved and the need for this plugin ceased to exist. The permission_handler is a full featured plugin for managing permissions and is actively maintained.


pub package

The Location Permissions plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to check and request permissions to access location services.

BranchBuild Status
developBuild Status
masterBuild Status

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: ^3.0.0

NOTE: The location_permissions plugin uses the AndroidX version of the Android Support Libraries. This means you need to make sure your Android project is also upgraded to support AndroidX. Detailed instructions can be found here.

The TL;DR version is:

  1. Add the following to your "gradle.properties" file:
android.useAndroidX=true
android.enableJetifier=true
  1. Make sure you set the compileSdkVersion in your "android/app/build.gradle" file to 28 or higher:
android {
 compileSdkVersion 28

 ...
}
  1. Make sure you replace all the android. dependencies to their AndroidX counterparts (a full list can be found here: https://developer.android.com/jetpack/androidx/migrate).

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

116
likes
0
pub points
96%
popularity

Publisher

baseflow.com

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.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on location_permissions