location_permissions 2.0.2

Flutter Location Permissions Plugin #

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

2.0.2 #

  • Fixed bug where method shouldShowRequestPermissionRationale always returns false.

2.0.1 #

  • Fixed a bug where permissions on iOS are not requested in some cases;
  • Updated examples in the README to match the instance methods introduced in version 2.0.0.

2.0.0 #

  • breaking Changed from static to instance methods to improve testability;
  • Added support for CocoaPods staticframework;
  • Cleaned up some duplicated code to make code-base easier to maintain.

1.1.0 #

  • Adds support to listen for location service availability using a stream on Android (on iOS this is ignored, since it isn't supported by Apple);
  • Fixed multi-dex and AndroidX support.

1.0.2 #

  • Use the correct homepage in the pubspec.yaml

1.0.1 #

  • Ignore warnings on iOS for calling deprecated methods (these are only called on older iOS platforms).

1.0.0 #

  • Initial release

example/README.md

location_permissions_example #

Demonstrates how to use the location_permissions plugin.

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:
  location_permissions: ^2.0.2

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:location_permissions/location_permissions.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
92
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
94
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (meta).

Dependencies

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