location 1.3.4

  • README.md
  • Example
  • Installing
  • Versions
  • 97

Flutter Location Plugin pub package

This plugin for Flutter handles getting location on Android and iOS. It also provides callbacks when location is changed.

Demo App

Getting Started

In order to use this plugin in Android, you have to add this permission in AndroidManifest.xml :

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

Permission check for Android 6+ was added. Still no callback when permissions granted so aiming SDK 21 is safer.

And to use it in iOS, you have to add this permission in Info.plist :


Then you just have to import the package with

import 'package:location/location.dart';

Look into the example for utilisation, but a basic implementation can be done like this for a one time location :

var currentLocation = <String, double>{};

var location = new Location();

// Platform messages may fail, so we use a try/catch PlatformException.
try {
  currentLocation = await location.getLocation;
} on PlatformException {
  currentLocation = null;

You can also get continuous callbacks when your position is changing:

var location = new Location();

location.onLocationChanged.listen((Map<String,double> currentLocation) {
  print(currentLocation["speed_accuracy"]); // Will always be 0 on iOS


In this table you can find the different functions exposed by this plugin:

Future<Map<String, double>>getLocation <br> Allow to get a one time position of the user.
Stream<Map<String, double>>onLocationChanged <br> Get the stream of the user's location.


Please feel free to give me any feedback helping support this plugin !

[1.3.4] 4th June 2018

  • Fix crash for Android API pre 27 thanks to matthewtsmith.

[1.3.3] 30th May 2018

  • Correct implementation of iOS plugin to match Android behaviour. No need to call getLocation to get permissions for location callbacks.

[1.3.2] 30th May 2018

  • Change implementation to api in build.gradle in order to solve incompatibilities between GMS versions thanks to luccascorrea

[1.3.1] 29th May 2018

  • Added speed and speed_accuracy (only Android truly discover speed accuracy, so its always 0 for now on iOS)
  • Solved a crash

[1.3.0] 27th May 2018

  • Make it compatible with Firebase thanks to quangIO
  • Resolve runtime error exception thanks to jharrison902
  • Update gitignore thanks to bcko

[1.2.0] 5th April 2018

  • Permissions denied on Android handled thanks to g123k
  • Dart 2 update thanks to efortuna

[1.1.6] - 19th Octobre 2017.

  • iOS code from Swift to Objective-C thanks to fluff

[1.1.1] - 20th July 2017.

  • Fixes for iOS result's format.

[1.1.0] - 17th July 2017.

  • Added permission check for Android 6+ (thanks netdur). Still no callback when permissions granted so aiming SDK 21 is safer.

[1.0.0] - 7th July 2017.

  • Initial Release.


import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:location/location.dart';

void main() {
  runApp(new MyApp());

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

class _MyAppState extends State<MyApp> {
  Map<String, double> _startLocation;
  Map<String, double> _currentLocation;

  StreamSubscription<Map<String, double>> _locationSubscription;

  Location _location = new Location();
  String error;

  bool currentWidget = true;

  Image image1;

  void initState() {


    _locationSubscription =
        _location.onLocationChanged.listen((Map<String,double> result) {
          setState(() {
            _currentLocation = result;

  // Platform messages are asynchronous, so we initialize in an async method.
  initPlatformState() async {
    Map<String, double> location;
    // Platform messages may fail, so we use a try/catch PlatformException.

    try {
      location = await _location.getLocation;

      error = null;
    } on PlatformException catch (e) {
      if (e.code == 'PERMISSION_DENIED') {
        error = 'Permission denied';
      } else if (e.code == 'PERMISSION_DENIED_NEVER_ASK') {
        error = 'Permission denied - please ask the user to enable it from the app settings';

      location = null;

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    //if (!mounted) return;

    setState(() {
        _startLocation = location;


  Widget build(BuildContext context) {
    List<Widget> widgets;

    if (_currentLocation == null) {
      widgets = new List();
    } else {
      widgets = [
        new Image.network(

    widgets.add(new Center(
        child: new Text(_startLocation != null
            ? 'Start location: $_startLocation\n'
            : 'Error: $error\n')));

    widgets.add(new Center(
        child: new Text(_currentLocation != null
            ? 'Continuous location: $_currentLocation\n'
            : 'Error: $error\n')));

    return new MaterialApp(
        home: new Scaffold(
            appBar: new AppBar(
              title: new Text('Location plugin example app'),
            body: new Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisSize: MainAxisSize.min,
              children: widgets,

Use this package as a library

1. Depend on it

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

  location: "^1.3.4"

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:location/location.dart';
Version Uploaded Documentation Archive
1.3.4 Jun 4, 2018 Go to the documentation of location 1.3.4 Download location 1.3.4 archive
1.3.3 May 30, 2018 Go to the documentation of location 1.3.3 Download location 1.3.3 archive
1.3.2 May 30, 2018 Go to the documentation of location 1.3.2 Download location 1.3.2 archive
1.3.1 May 29, 2018 Go to the documentation of location 1.3.1 Download location 1.3.1 archive
1.3.0 May 24, 2018 Go to the documentation of location 1.3.0 Download location 1.3.0 archive
1.2.0 Apr 5, 2018 Go to the documentation of location 1.2.0 Download location 1.2.0 archive
1.1.7 Nov 29, 2017 Go to the documentation of location 1.1.7 Download location 1.1.7 archive
1.1.6 Oct 19, 2017 Go to the documentation of location 1.1.6 Download location 1.1.6 archive
1.1.5 Oct 15, 2017 Go to the documentation of location 1.1.5 Download location 1.1.5 archive
1.1.4 Sep 12, 2017 Go to the documentation of location 1.1.4 Download location 1.1.4 archive

All 17 versions...


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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4


Describes how popular the package is relative to other packages. [more]
97 / 100
Code health derived from static analysis. [more]
94 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run flutter format to format lib/location.dart.


Package Constraint Resolved Available
Direct dependencies
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7