location_permissions 2.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 99

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:

  location_permissions: ^2.0.5

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:
  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).


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)
  /// Android: Fine and Coarse Location
  /// iOS: CoreLocation - Always

  /// Android: Fine and Coarse Location
  /// iOS: CoreLocation - WhenInUse

Status of the permission #

Defines the state of a location permissions

enum PermissionStatus {
  /// Permission to access the location services is denied by the user.

  /// Permission to access the location services is granted by the user.

  /// The user granted restricted access to the location services (only on iOS).

  /// Permission is in an unknown state

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.

  /// Location services are not available on the device.

  /// The location services are disabled.

  /// The location services are 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.5 #

  • iOS: fixed bug where permssions for locationWhenInUse are reported as denied incorrectly.

2.0.4+1 #

  • Fixed merge conflict

2.0.4 #

  • Synchronized Gradle and Gradle Wrapper with Flutter stable (1.12.13+hotfix.5)
  • Added support for Flutter analysis

2.0.3 #

  • Added support for Android 10 background permissions;
  • Ensure shouldShowRequestPermissionRationale is executed on the Android Activity.

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


import 'dart:io';

import 'package:flutter/material.dart';
import 'package:location_permissions/location_permissions.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
          actions: <Widget>[
              icon: const Icon(Icons.settings),
              onPressed: () {
                LocationPermissions().openAppSettings().then((bool hasOpened) =>
                    debugPrint('App Settings opened: ' + hasOpened.toString()));
        body: Center(
          child: ListView(
            children: createWidgetList(),

  List<Widget> createWidgetList() {
    final List<Widget> widgets = LocationPermissionLevel.values
        .map<Widget>((LocationPermissionLevel level) => PermissionWidget(level))

    if (Platform.isAndroid) {

    return widgets;

class StreamingStatusWidget extends StatelessWidget {
  final Stream<ServiceStatus> statusStream =

  Widget build(BuildContext context) => ListTile(
        title: const Text('ServiceStatus'),
        subtitle: StreamBuilder<ServiceStatus>(
          stream: statusStream,
          initialData: ServiceStatus.unknown,
          builder: (_, AsyncSnapshot<ServiceStatus> snapshot) =>

class PermissionWidget extends StatefulWidget {
  const PermissionWidget(this._permissionLevel);

  final LocationPermissionLevel _permissionLevel;

  _PermissionState createState() => _PermissionState(_permissionLevel);

class _PermissionState extends State<PermissionWidget> {

  final LocationPermissionLevel _permissionLevel;
  PermissionStatus _permissionStatus = PermissionStatus.unknown;

  void initState() {


  void _listenForPermissionStatus() {
    final Future<PermissionStatus> statusFuture =

    statusFuture.then((PermissionStatus status) {
      setState(() {
        _permissionStatus = status;

  Color getPermissionColor() {
    switch (_permissionStatus) {
      case PermissionStatus.denied:
        return Colors.red;
      case PermissionStatus.granted:
        return Colors.green;
        return Colors.grey;

  Widget build(BuildContext context) {
    return ListTile(
      title: Text(_permissionLevel.toString()),
      subtitle: Text(
        style: TextStyle(color: getPermissionColor()),
      trailing: IconButton(
          icon: const Icon(Icons.info),
          onPressed: () {
            checkServiceStatus(context, _permissionLevel);
      onTap: () {

  void checkServiceStatus(
      BuildContext context, LocationPermissionLevel permissionLevel) {
        .then((ServiceStatus serviceStatus) {
      final SnackBar snackBar =
          SnackBar(content: Text(serviceStatus.toString()));


  Future<void> requestPermission(
      LocationPermissionLevel permissionLevel) async {
    final PermissionStatus permissionRequestResult = await LocationPermissions()
        .requestPermissions(permissionLevel: permissionLevel);

    setState(() {
      _permissionStatus = permissionRequestResult;

Use this package as a library

1. Depend on it

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

  location_permissions: ^2.0.5

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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on May 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev
  • Flutter: 1.17.1


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
meta ^1.1.6 1.1.8
Transitive dependencies
collection 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
pedantic 1.8.0+1