locate 1.1.0

  • README.md
  • Example
  • Installing
  • Versions
  • 72

locate #

A Flutter plugin to work with Android Location Services(GPS/ Network).

usage #

This flutter plugin can be used on Android for fetching Location Data using either Google Play Services based Location or LocationManager based Location.

Well this plugin is has androidX support enabled.

Even you can specify whether to use Network provider or GPS provider as Location Data Provider.

Don't forget to add following permission in you AndroidManifest.xml.

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

If you're planning to use Google Play Services based FusedLocationProvider, request for ACCESS_FINE_LOCATION.

Otherwise you may only request for ACCESS_COARSE_LOCATION.

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

how to use API #

Get an intance of Locate class.

var _locate = Locate();

Make sure you first request for Location Permission from user.

_locate.requestLocationPermission().then((bool result) {
                  if (result)
                    // we're good to go
                    // you may be interested in letting user know about it, that location access permission is required

Now time to enable Location.

_locate.enableLocation().then((bool result) {
                      if (result) {
                        // setState(() => _areWeGettingLocationUpdate = true);
                        // here you may be interested in updating UI and the request for location Data.
                        // Location data will be fetched and delivered as Stream<MyLocation>
                        // user didn't enable location

And finally, let's request for getting Location Data Feed.

                            // we listen for location data, which is received as stream
                            (MyLocation data) =>
                                setState(() => _locationData.add(data)), // as soon as data received,will update UI/ perform some other task using location data.
                            cancelOnError: true, // if some error occurs, Stream will be closed
                            onError: (e) => print(e), // error is displayed

Aah I just forgot to mention one thing, how to stop listening location update.

_locate.stopLocationDataFeed().then((bool result) {
  // do some UI updation kind of work/ or something else

what's MyLocation #

MyLocation class can be thought of as a Location Data Container.

/// constructor of MyLocation
      this.time, // in DateTime
      this.altitude, // in meters
      this.bearing, // in degree
      this.speed, // in meters/s
      this.accuracy, // in meters
      this.verticalAccuracy, // in meters
      this.bearingAccuracy, // in meters
      this.speedAccuracy, // in meters/s
      this.provider, // as String,either gps/ network/ fused

I've added some companion methods which can be used from MyLocation, such as

// will fetch you name of direction of movement from bearing value

// m/s to km/h converion for speedaccuracy

/// same as above, but works on speed

/// displays time in pretty format

important points #

You can also set some optional named parameters while invoking methods from Locate class.

In case of following method, you can also set provider, to be LocationProvider.Network, if you want to use Network based Location only.

      {String provider: LocationProvider.GPS}); // default value is LocationProvider.GPS

Before requesting Location Data Feed, you can also set via which location manager to fetch data and location data provider name.

Note:: If you are planning use LocationServiceProvider.GMSBasedLocation, for fetching data, make sure you've requested for permission of accessing FINE Location. And also use LocationProvider.GPS as locationProvider parameter's value.

Otherwise while using LocationServiceProvider.LocationManagerBasedLocation as locationServiceProvider, you may either use LocationProvider.GPS or LocationProvider.Network, depending upon your requested permissions.

      {String locationServiceProvider:
      String locationProvider: LocationProvider.GPS});

If you've FINE Location access permission, you can simply request for Network Provider based location data.

Hope it was helpful.

Show some <3, to this venture, by putting star on GitHub.

1.0.0 #

This is the very first release of locate flutter plugin. It simply fetches android location data using either Google Play Service based Location Service or android.location.LocationManager. It can continously report device location using callback mechanism, which might be used to update UI.

This plugin only works for Androd Platform. Built with latest version of SDK(28).

1.1.0 #

Very happy to release a new version of this plugin.

In this release locate, tries to leverage the power of Asynchronous Programming, based on Future

If you've been using it, we'll this might be a bad situttion, but it's a breaking update.

API has been updated, for ease of usability. No callbacks anymore for receiving location data feed, a Stream

Hope it'll be helpful.


locate_example #

Demonstrates how to use the locate plugin.

screen captures #





Hope it was helpful :)

Use this package as a library

1. Depend on it

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

  locate: ^1.1.0

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:locate/locate.dart';
Version Uploaded Documentation Archive
1.1.0 May 8, 2019 Go to the documentation of locate 1.1.0 Download locate 1.1.0 archive
1.0.0 Mar 6, 2019 Go to the documentation of locate 1.0.0 Download locate 1.0.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.

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

  • Dart: 2.3.1
  • pana: 0.12.17
  • Flutter: 1.5.4-hotfix.2


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/my_location.dart.

Run flutter format to format lib/my_location.dart.

Maintenance suggestions

The package description is too short. (-4 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies