• Stars
    star
    636
  • Rank 70,203 (Top 2 %)
  • Language
    Dart
  • License
    Other
  • Created about 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sophisticated, battery-conscious background-geolocation & geofencing with motion-detection

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.


Google Play

Home Settings

Contents

🔷 Installing the Plugin

📂 pubspec.yaml:

Note: See Versions for latest available version.

dependencies:
  flutter_background_geolocation: '^4.12.0'

Or latest from Git:

dependencies:
  flutter_background_geolocation:
    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> {

  @override
  void initState() {
    super.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
    //
    bg.BackgroundGeolocation.ready(bg.Config(
        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.
        //
        bg.BackgroundGeolocation.start();
      }
    });
  }
}

⚠️ 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.

Google Play

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.

License

The MIT License (MIT)

Copyright (c) 2018 Chris Scott, Transistor Software

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
Objective-C
2,613
star
2

react-native-background-fetch

Periodic callbacks in the background for both IOS and Android
Java
1,466
star
3

cordova-background-geolocation-lt

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

flutter_background_fetch

Periodic callbacks in the background for both IOS and Android. Includes Android Headless mechanism
Dart
566
star
5

cordova-plugin-background-fetch

Implements background fetching of data.
Objective-C
296
star
6

rn-background-geolocation-demo

Demo app for react-native-background-geolocation plugin
TypeScript
201
star
7

background-geolocation-console

A field-testing & analysis server for the Background Geolocation plugin
JavaScript
148
star
8

cordova-background-geolocation-SampleApp

Cordova Background Geolocation Sample Application
TypeScript
121
star
9

capacitor-background-geolocation

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

capacitor-background-fetch

Periodic callbacks in the background for both IOS and Android
TypeScript
78
star
11

nativescript-background-geolocation-lt

Sophisticated, battery-conscious, cross-platform background-geolocation with motion-detection and geofencing
TypeScript
73
star
12

background-geolocation-lt

Advanced Background Geolocation & Geofencing SDK for iOS & Android
Objective-C
48
star
13

nativescript-background-fetch

iOS Background Fetch API Implementation for NativeScript
TypeScript
28
star
14

react-native-background-geolocation-firebase

Firebase Adapter for React Native Background Geolocation
Objective-C
24
star
15

flutter_background_geolocation_firebase

Firebase proxy for Flutter Background Geolocation SDK
Dart
21
star
16

transistor-background-fetch

Native iOS / Android Background Fetch Implementation
Java
20
star
17

cordova-google-api-version

Cordova plugin to solve Google API version conflicts by pining a desired version for all Google APIs (eg: play-services, firebase)
JavaScript
18
star
18

expo-gradle-ext-vars

TypeScript
8
star
19

cordova-background-geolocation-firebase

Firebase Adapter for Cordova Background Geolocation
Objective-C
7
star
20

capacitor-background-geolocation-firebase

Firebase adapter for Capacitor Background Geolocation
TypeScript
6
star
21

location-push-service-demo

A simple script to send an iOS Location Push Service request to a device directly through APNS. This is a demo of how your server might send an iOS Location Push Service request
JavaScript
6
star
22

background-geolocation-firebase

Firebase proxy for Background Geolocation SDK (pure native version)
Objective-C
2
star
23

flutter_hello_world

Hello World for issue https://github.com/transistorsoft/flutter_background_geolocation/issues/169
Dart
1
star
24

cordova-background-geolocation-broadcast-receiver

This plugin is designed for use with the Android platform of the Cordova Background Geolocation plugin. The plugin will add an Android BroadcastReceiver to your application, capable of receiving events from the BackgroundGeolocation plugin in the native Android environment.
Java
1
star