geolocation 0.1.1

  • Example
  • Installing
  • Versions
  • 45

Geolocation #

Flutter geolocation plugin working on Android API 16+ and iOS 9+.


  • Managing permissions automatically
  • Retrieving last known location
  • Requesting single location update

The plugin is under active development and the following features are planned soon:

  • Continuous location updates with foreground and background strategies
  • Geocode
  • Geofences
  • Place suggestions
  • Activity recognition

Installation #

Add geolocation to your pubspec.yaml:

  geolocation: ^0.1.1

Note: There is a known issue for integrating swift written plugin into Flutter project created with Objective-C template. See #16049 for help on integration.

Permission #

Apps need to declare the desired location permission in configuration file and request it at runtime. Geolocation plugin automatically checks at runtime if the configuration is correct, and throws an exception otherwise.

iOS configuration #

There are two kinds of location permission in iOS: "when in use" and "always". You will request one or another depending if the app requires to use location while being in background. You need to specify the description for the desired permission in Infos.plist.

When targeting iOS 9/10: NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription

When targeting iOS 11+: NSLocationAlwaysAndWhenInUseUsageDescription or NSLocationWhenInUseUsageDescription

Geolocation will automatically request the associated permission at runtime, based on the content of Infos.plist.

Android configuration #

There are two kinds of location permission in Android: "coarse" and "fine". Coarse location will allow to get approximate location based on sensors like the Wifi, while fine location returns the most accurate location using GPS (in addition to coarse).

You need to declare one of those permissions in AndroidManifest.xml:

<manifest xmlns:android=""
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <!-- or -->
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


Runtime request #

On Android (api 23+) and iOS, apps need to request permission at runtime. Geolocation plugin handles this automatically. If the user denies location permission, location result will return an error of type GeolocationResultErrorType.permissionDenied.

Location API #

Get the last known location #

See api documentation: [link]

LocationResult result = await Geolocation.lastKnownLocation;

Get the current location #

See api documentation: [link]

LocationResult result = await Geolocation.currentLocation(;

Get a single location update #

See api documentation: [link]

LocationResult result = await Geolocation.singleLocationUpdate(;

Result #

All location API return a LocationResult future.

final LocationResult result = await Geolocation.lastKnownLocation;

if (result.isSuccessful) {
  // location request successful, location is guaranteed to not be null 
  double lat = result.location.latitude;
  double lng = result.location.longitude;
} else {
  switch (result.error.type) {
    case GeolocationResultErrorType.runtime:
      // runtime error, check result.error.message
    case GeolocationResultErrorType.locationNotFound:
      // location request did not return any result
    case GeolocationResultErrorType.serviceDisabled:
      // location services disabled on device
      // might be that GPS is turned off, or parental control (android) 
    case GeolocationResultErrorType.permissionDenied:
      // user denied location permission request
      // rejection is final on iOS, and can be on Android
      // user will need to manually allow the app from the settings
    case GeolocationResultErrorType.playServicesUnavailable:
      // android only
      // result.error.additionalInfo contains more details on the play services error
      switch(result.error.additionalInfo as GeolocationAndroidPlayServices) {
        // do something, like showing a dialog inviting the user to install/update play services
        case GeolocationAndroidPlayServices.missing:
        case GeolocationAndroidPlayServices.updating:
        case GeolocationAndroidPlayServices.versionUpdateRequired:
        case GeolocationAndroidPlayServices.disabled:
        case GeolocationAndroidPlayServices.invalid:

Author #

Geolocation plugin is developed by Loup, a mobile development studio based in Montreal and Paris.
You can contact us at

License #

Apache License 2.0


  • Pubspec and documentation fixes

[0.1.0] - Initial release

  • New feature: Last known location
  • New feature: Current location
  • New feature: Location updates


//  Copyright (c) 2018 Loup Inc.
//  Licensed under Apache License v2.0

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'tab_location.dart';

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

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new CupertinoTabScaffold(
        tabBar: new CupertinoTabBar(
          items: <BottomNavigationBarItem>[
            new BottomNavigationBarItem(
              title: new Text('Current'),
              icon: new Icon(Icons.location_on),
            new BottomNavigationBarItem(
              title: new Text('Track'),
              icon: new Icon(Icons.location_searching),
            new BottomNavigationBarItem(
              title: new Text('Geocode'),
              icon: new Icon(Icons.location_city),
        tabBuilder: (BuildContext context, int index) {
          return new CupertinoTabView(
            builder: (BuildContext context) {
              switch (index) {
                case 0:
                  return new TabLocation();
                  return new Container(
                    child: new Center(
                      child: new Text('TBD'),

Use this package as a library

1. Depend on it

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

  geolocation: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:geolocation/geolocation.dart';
Version Uploaded Documentation Archive
0.2.1 Apr 12, 2018 Go to the documentation of geolocation 0.2.1 Download geolocation 0.2.1 archive
0.2.0 Apr 12, 2018 Go to the documentation of geolocation 0.2.0 Download geolocation 0.2.0 archive
0.1.1 Apr 3, 2018 Go to the documentation of geolocation 0.1.1 Download geolocation 0.1.1 archive
0.1.0 Apr 3, 2018 Go to the documentation of geolocation 0.1.0 Download geolocation 0.1.0 archive
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.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK <2.0.0