Skip to content
pubscout

background_location_tracker

1.6.1, released a year ago by icapps.com

Track background location for Android and iOS

WASM-ready
$ flutter pub add background_location_tracker
Source repository

What it does

Allows your Flutter application to continuously track device location in the background on both Android and iOS. It utilizes a background callback to process location updates even when the app is minimized or terminated.

AI-written summary of version 1.6.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to continuously track user locations in the background on Android and iOS.
  • You require background callbacks to save or upload location updates while the app is closed.

Skip it when

  • You only need foreground location tracking.
  • You do not want to configure native platform settings like Info.plist or Android SDK configurations.

Strengths

  • Supports both Android and iOS background location tracking.
  • Provides configuration options for tracking intervals, distance filters, and activity types.

Weaknesses

  • Requires manual native configuration steps on both Android and iOS.
  • Relies on deprecated setPluginRegistrantCallback patterns for older compatibility or specific iOS setups.

Setup

Kind
Plugin (native code)
Effort
High
Code generation
No
Direct dependencies
0

Requires setting compile SDK to at least 29 and configuring foreground service permissions on Android. On iOS, you must add permission descriptions for location usage, UIBackgroundModes location setting, and update the AppDelegate to register background plugins.

@pragma('vm:entry-point')
void backgroundCallback() {
  BackgroundLocationTrackerManager.handleBackgroundUpdated(
    (data) async => Repo().update(data),
  );
}

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await BackgroundLocationTrackerManager.initialize(
    backgroundCallback,
    config: const BackgroundLocationTrackerConfig(
      loggingEnabled: true,
      androidConfig: AndroidConfig(
        notificationIcon: 'explore',
        trackingInterval: Duration(seconds: 4),
        distanceFilterMeters: null,
      ),
      iOSConfig: IOSConfig(
        activityType: ActivityType.FITNESS,
        distanceFilterMeters: null,
        restartAfterKill: true,
      ),
    ),
  );

  runApp(MyApp());
}

Alternatives

Packages that do the same job and could replace background_location_tracker.

  • geolocator

    A widely used, comprehensive geolocation plugin that supports background tasks and location streams.