Flutter Background Execution Sample - LocationBackgroundPlugin

An example Flutter plugin that showcases background execution using iOS location services.

This plugin is not being actively maintained and is not for production use. An archive of previous versions can be found in the Flutter plugins repository.

Getting Started

NOTE: This plugin does not currently have an Android implementation.

To import, add the following to your Dart file:

import 'package:location_background/location_background.dart';

Example usage:

import 'package:location_background/location_background.dart';

final locationManager = LocationBackgroundPlugin();

void locationUpdateCallback(Location location) {
  print('Location Update: $location');
}

Future<void> startMonitoringLocationChanges() =>
    locationManager.monitorSignificantLocationChanges(locationUpdateCallback);
    
Future<void> stopMonitoringLocationChanges() =>
    locationManager.cancelLocationUpdates();

WARNING: do not maintain volatile state or perform long running operations in the location update callback. There is no guarantee from the system for how long a process can perform background processing after a location update, and the Dart isolate may shutdown during execution at the request of the system.

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Libraries

location_background_plugin

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.