geolocator 1.3.0

  • Example
  • Installing
  • Versions
  • new91

Flutter Geolocator Plugin

pub package

A Flutter geolocation plugin which provides easy access to the platform specific location services (LocationManager on Android and CLLocationManager on iOS).

BranchBuild Status
developBuild Status
masterBuild Status


  • Get the current location of the device;
  • Get continuous location updates;
  • Translate an address to geocoordinates and vice verse (a.k.a. Geocoding);
  • Calculate the distance (in meters) between two geocoordinates.


To use this plugin, add geolocator as a dependency in your pubspec.yaml file. For example:

  geolocator: '^1.3.0'

NOTE: There's a known issue with integrating plugins that use Swift into a Flutter project created with the Objective-C template. See issue Flutter#16049 for help on integration.



To query the current location of the device simply make a call to the getPosition method:

import 'package:geolocator/geolocator.dart';
import 'package:geolocator/models/location_accuracy.dart';
import 'package:geolocator/models/position.dart';

Position position = await Geolocator().getPosition(LocationAccuracy.High);

To listen for location changes you can subscribe to the onPositionChanged stream. Supply an instance of the LocationOptions class to configure the desired accuracy and the minimum distance change (in meters) before updates are send to the application.

import 'package:geolocator/geolocator.dart';
import 'package:geolocator/models/location_accuracy.dart';
import 'package:geolocator/models/position.dart';

var geolocator = Geolocator();
var locationOptions = LocationOptions(accuracy: LocationAccuracy.High, distanceFilter: 10);

StreamSubscription<Position> positionStream = geolocator.getPositionStream(locationOptions).listen(
    (Position position) {
        print(_position == null ? 'Unknown' : _position.latitude.toString() + ', ' + _position.longitude.toString());


To translate an address into latitude and longitude coordinates you can use the toPlacemark method:

import 'package:geolocator/geolocator.dart';
import 'package:geolocator/models/placemark.dart';

Placemark placemark = await Geolocator().toPlacemark("Gronausestraat 710, Enschede");

If you want to translate latitude and longitude coordinates into an address you can use the fromPlacemark method:

import 'package:geolocator/geolocator.dart';
import 'package:geolocator/models/placemark.dart';

Placemark placemark = await new Geolocator().toPlacemark(52.2165157, 6.9437819);

Calculate distance

To calculate the distance (in meters) between two geocoordinates you can use the distanceBetween method. The distanceBetween method takes four parameters:

startLatitudedoubleLatitude of the start position
startLongitudedoubleLongitude of the start position
endLatitudedoubleLatitude of the destination position
endLongitudedoubleLongitude of the destination position
import 'package:geolocator/geolocator.dart';

double distanceInMeters = await new Geolocator().distanceBetween(52.2165157, 6.9437819, 52.3546274, 4.8285838);

See also the example project for a complete implementation.



On Android you'll need to add the ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions to your Android Manifest. Todo so open the AndroidManifest.xml file and add the following two lines as direct children of the <manifest> tag:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />


On iOS you'll need to add the NSLocationWhenInUseUsageDescription to your Info.plist file in order to access the device's location. Simply open your Info.plist file and add the following:

<string>This app needs access to location when open.</string>

If you would like to access the device's location when your App is running in the background, you should also add the NSLocationAlwaysAndWhenInUseUsageDescription (if your App support iOS 10 or earlier you should also add the key NSLocationAlwaysUsageDescription) key to your Info.plist file:

<string>This app needs access to location when in the background.</string>
<string>This app needs access to location when open and in the background.</string>

Location accuracy

The table below outlines the accuracy options per platform:

Medium100 - 500m100m
High0 - 100m10m
Best0 - 100m~0m


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.


This Geolocator plugin for Flutter is developed by Baseflow. You can contact us at


  • Added the option to check the distance between two geocoordinates (using the distanceBetween method).


  • Make sure that an Android App using the plugin is informed when the platform stops transmitting location updates.


  • Added feature to throttle the amount of locations updates based on a supplied distance filter.


This introduces a breaking change since the signature of the getPositionStream has changed from getPositionStream(LocationAccuracy accuracy) to getPositionStream(LocationOptions locationOptions) .

  • Made some small changes to ensure the plugin no longer is depending on JAVA 8, meaning the plugin will run using the default Android configuration.


  • Added support to translate an address into geocoordinates and vice versa (a.k.a. Geocoding). See the file for more information.


  • Fixed reported formatting issues


  • Fixed a warning generated by xCode when compiling the example project (see issue #28)
  • Fixed some warnings generated by Dart static code analyser, improving code quality


  • Introduced the option to supply a desired accuracy.


This introduces a breaking change, the getPosition and onPositionChanged properties have been replaced by methods (getPosition([LocationAccuracy desiredAccuracy = LocationAccuracy.Best]) and getPositionStream([LocationAccuracy desiredAccuracy = LocationAccuracy.Best]) respectively) accepting a parameter to indicate the desired accuracy.


  • Updated documentation
  • API defined stable


  • Solved problem with missing geolocator-Swift.h header file (see also issue Flutter#16049).


  • Initial release


import 'package:flutter/material.dart';
import 'package:geolocator_example/widgets/calculate_distance_widget.dart';
import 'package:geolocator_example/widgets/current_location_widget.dart';
import 'package:geolocator_example/widgets/lookup_address_widget.dart';
import 'package:geolocator_example/widgets/lookup_coordinates_widget.dart';

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

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
        home: new Scaffold(
            appBar: new AppBar(
              title: new Text('Plugin example app'),
            body: new Center(
              child: new Column(
                children: <Widget>[
                  new CurrentLocationWidget(),
                  new Divider(),
                  new LookupAddressWidget(),
                  new Divider(),
                  new LookupCoordinatesWidget(),
                  new Divider(),
                  new CalculateDistanceWidget(),

Use this package as a library

1. Depend on it

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

  geolocator: ^1.3.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support 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:geolocator/geolocator.dart';
Version Uploaded Documentation Archive
1.3.0 Jul 20, 2018 Go to the documentation of geolocator 1.3.0 Download geolocator 1.3.0 archive
1.2.2 Jul 13, 2018 Go to the documentation of geolocator 1.2.2 Download geolocator 1.2.2 archive
1.2.1 Jul 12, 2018 Go to the documentation of geolocator 1.2.1 Download geolocator 1.2.1 archive
1.2.0 Jul 10, 2018 Go to the documentation of geolocator 1.2.0 Download geolocator 1.2.0 archive
1.1.2 Jul 6, 2018 Go to the documentation of geolocator 1.1.2 Download geolocator 1.1.2 archive
1.1.1 Jul 6, 2018 Go to the documentation of geolocator 1.1.1 Download geolocator 1.1.1 archive
1.1.0 Jul 3, 2018 Go to the documentation of geolocator 1.1.0 Download geolocator 1.1.0 archive
1.0.0 Jun 29, 2018 Go to the documentation of geolocator 1.0.0 Download geolocator 1.0.0 archive
0.0.2 Jun 27, 2018 Go to the documentation of geolocator 0.0.2 Download geolocator 0.0.2 archive
0.0.1 Jun 22, 2018 Go to the documentation of geolocator 0.0.1 Download geolocator 0.0.1 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.

We analyzed this package on Jul 20, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.69.0
  • pana: 0.11.7
  • Flutter: 0.5.5


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
meta ^1.0.5 1.1.5 1.1.6
Transitive dependencies
collection 1.14.6 1.14.11
sky_engine 0.0.99
typed_data 1.1.5 1.1.6
vector_math 2.0.6 2.0.7
Dev dependencies
mockito ^2.0.2