Skip to content

Examples

Basic tracking

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

// Use the 'bg' namespace to avoid conflicts with Flutter's own Location/State types.
bg.BackgroundGeolocation.ready(bg.Config(
  geolocation: bg.GeoConfig(
    desiredAccuracy: bg.DesiredAccuracy.high,
    distanceFilter: 10.0,
  ),
  app: bg.AppConfig(
    stopOnTerminate: false,
    startOnBoot: true,
  ),
  logger: bg.LoggerConfig(
    debug: true,
    logLevel: bg.LogLevel.verbose,
  ),
)).then((bg.State state) {
  if (!state.enabled) {
    bg.BackgroundGeolocation.start();
  }
});