---
title: Permissions
description: Manually handle permissions
---

# Permissions

The package has been designed so you don't need to handle permissions manually.
The first call to `getLocation` or `onLocationChanged` will automatically request the permissions.

If you need to handle the permissions manually you can still use the `requestPermission` method.

## Get Permission Status

```dart
Future<PermissionStatus> hasPermission()
```

If the status is `PermissionStatus.granted` or `PermissionStatus.grantedLimited` you can use the `getLocation` method.

If the status is `PermissionStatus.denied` you can use the `requestPermission` method to ask the user for the permission.

If the status is `PermissionStatus.deniedForever` your user will not be shown the permission popup the next time. The next location request will probably fail.
You should request the user to manually change the settings of the app.

## Request Permission

```dart
Future<PermissionStatus> requestPermission()
```

A dialog will be shown to the user if the location has not been granted yet.
If a reduced precision permission has been given (`PermissionStatus.grantedLimited`), the user will be asked to grant the precise permission.

## Background Permission

To keep receiving location updates while the app is in the background, the user
must grant "Allow all the time" (Always) access on top of the foreground grant.
You can check whether that has been granted with:

```dart
Future<bool> isBackgroundPermissionGranted()
```

Use it before calling `enableBackgroundMode` to decide whether to show an in-app
rationale before sending the user to the system settings.

- **iOS / macOS:** `true` only when the authorization status is "Always".
- **Android:** reflects the `ACCESS_BACKGROUND_LOCATION` runtime permission on
  API 29+ (Android 10). On older versions background access is implied by the
  foreground grant, so this mirrors `hasPermission`.
- **Web:** always `false`.

```dart
final location = Location();
if (!await location.isBackgroundPermissionGranted()) {
    // Show your own explanation, then guide the user to settings.
}
```

## Examples

### Getting permission status

```dart
final location = Location();
final permission = await location.hasPermission();
if (permission == PermissionStatus.denied) {
    print("The user will not allow you to use the location");
}
```
