flutter_location_services 0.0.1 copy "flutter_location_services: ^0.0.1" to clipboard
flutter_location_services: ^0.0.1 copied to clipboard

A robust Flutter package for live location tracking with background support, geofencing, routing, and Firebase synchronization.

Flutter Location Services #

A simple, all-in-one package for live location tracking, geofencing, routing, and background data synchronization.

Features #

  • 📍 Live Tracking: Get user location in foreground & background.
  • 🔋 Battery Efficient: Uses persistent foreground services for reliable background tracking.
  • 🚧 Geofencing: Easy-to-use "Enter" and "Exit" region events.
  • 🛣️ Routing: Draw routes on Google Maps with one line of code.
  • ☁️ Firebase Sync: Automatically sync location data to your cloud database.

Quick Start #

1. Installation #

Add to your pubspec.yaml:

dependencies:
  flutter_location_services: ^0.0.1

2. Basic Usage #

Initialize the package in your main() method:

import 'package:flutter_location_services/flutter_location_services.dart';

void main() {
  SmartLocation.configure(
    apiKey: 'YOUR_GOOGLE_MAPS_API_KEY', // Required for Maps & Routing
    debugMode: true, // See logs in console
  );
  runApp(MyApp());
}

3. Start Tracking #

To start tracking location (even when app is closed):

await SmartLocation.startBackgroundTracking();

To stop:

await SmartLocation.stopBackgroundTracking();

4. Routing #

Get a route between two points:

final route = await SmartLocation.getRoute(
  source: LatLng(37.4, -122.0), 
  destination: LatLng(37.5, -122.1),
);

// Display the route on your map
// (See example app for full UI implementation)

5. Geofencing #

Trigger actions when a user enters a specific area:

SmartLocation.addGeofence(
  GeofenceRegion(
    id: 'home',
    latitude: 37.422,
    longitude: -122.084,
    radiusMeters: 200,
    onEnter: (_) => print('Welcome Home!'),
    onExit: (_) => print('Goodbye!'),
  ),
);

Setup Guide #

Android #

  1. Add permissions to android/app/src/main/AndroidManifest.xml:
    • ACCESS_FINE_LOCATION
    • ACCESS_BACKGROUND_LOCATION
    • FOREGROUND_SERVICE
  2. Add your Google Maps API Key in AndroidManifest.xml.

iOS #

  1. Add NSLocationAlwaysAndWhenInUseUsageDescription to Info.plist.
  2. Enable "Background Modes" -> "Location updates" in Xcode.

Created with ❤️ for the Flutter community.

0
likes
140
points
34
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A robust Flutter package for live location tracking with background support, geofencing, routing, and Firebase synchronization.

Repository (GitHub)

License

MIT (license)

Dependencies

dio, equatable, flutter, flutter_background_service, flutter_local_notifications, geolocator, google_maps_flutter, google_polyline_algorithm, permission_handler, rxdart, shared_preferences

More

Packages that depend on flutter_location_services