Flutter Background Geolocation


The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.

The plugin’s Philosophy of Operation is to use motion-detection APIs (using accelerometer, gyroscope and magnetometer) to detect when the device is moving and stationary.

  • When the device is detected to be moving, the plugin will automatically start recording a location according to the configured distanceFilter (meters).

  • When the device is detected be stationary, the plugin will automatically turn off location-services to conserve energy.

Also available for Cordova, React Native, NativeScript and pure native apps.

The Android module requires purchasing a license. However, it will work for DEBUG builds. It will not work with RELEASE builds without purchasing a license.

(2018) This plugin is supported full-time and field-tested daily since 2013.

Home Settings

🔷 Installing the Plugin

📂 pubspec.yaml:

Note: See Versions for latest available version.

  flutter_background_geolocation: '^1.9.0'

Or latest from Git:

      url: https://github.com/transistorsoft/flutter_background_geolocation.git

🔷 Setup Guides

🔷 Using the plugin

import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;

⚠️ Note as bg in the import. This is important to namespace the plugin’s classes, which often use common class-names such as Location, Config, State. You will access every flutter_background_geolocation class with the prefix bg (ie: “background geolocation”).

🔷 Example

Full Example

There are three main steps to using BackgroundGeolocation:

  1. Wire up event-listeners.
  2. Configure the plugin with #ready.
  3. #start the plugin.
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;

class _MyHomePageState extends State<MyHomePage> {

  void initState() {

    // 1\.  Listen to events (See docs for all 12 available events).

    // Fired whenever a location is recorded
    bg.BackgroundGeolocation.onLocation((bg.Location location) {
      print('[location] - $location');

    // Fired whenever the plugin changes motion-state (stationary->moving and vice-versa)
    bg.BackgroundGeolocation.onMotionChange((bg.Location location) {
      print('[motionchange] - $location');

    // Fired whenever the state of location-services changes.  Always fired at boot
    bg.BackgroundGeolocation.onProviderChange((bg.ProviderChangeEvent event) {
      print('[providerchange] - $event');

    // 2\.  Configure the plugin
        desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH,
        distanceFilter: 10.0,
        stopOnTerminate: false,
        startOnBoot: true,
        debug: true,
        logLevel: bg.Config.LOG_LEVEL_VERBOSE
    )).then((bg.State state) {
      if (!state.enabled) {
        // 3\.  Start the plugin.

⚠️ Do not execute any API method which will require accessing location-services until the callback to **#ready* executes (eg: #getCurrentPosition, #watchPosition, #start).

🔷 Demo Application

A fully-featured Demo App is available in the repo in the /example folder.

Home Settings

🔷 Simple Testing Server

A simple Node-based web-application with SQLite database is available for field-testing and performance analysis. If you’re familiar with Node, you can have this server up-and-running in about one minute.

Download Details:

Author: transistorsoft

Demo: https://www.transistorsoft.com/shop/products/flutter-background-geolocation

Source Code: https://github.com/transistorsoft/flutter_background_geolocation

#flutter #dart #mobile-apps

Flutter Background Geolocation
59.35 GEEK