Location Pro πŸ“

A Flutter service for real-time location tracking with real-time address tracking.

It also supports direct LatLng input, allowing you to fetch addresses without live GPS, and provides multi-language address support for English, Bangla, Japanese, Chinese, and more.


✨ Features

  • πŸ“‘ Real-time GPS tracking on mobile
  • 🌍 Periodic location updates on web/desktop
  • πŸ—ΊοΈ Reverse geocoding with Nominatim API
  • πŸ”” Exposes current LatLng & address as ValueNotifier
  • πŸ“ Supports direct LatLng input: startTracking(LatLng)
  • 🌐 Multi-language address support (English, Bangla, Japanese, Chinese, etc.)
  • πŸ“± Cross-platform (Android, iOS, Web, Desktop)
  • 🚦 Automatic permission handling

πŸ“¦ Installation

Add the package to your pubspec.yaml:

dependencies:
  location_pro: ^1.0.0

Then run:

flutter pub get

Import the service:

import 'package:location_pro/location_pro.dart';

πŸ› οΈ Usage

Initialize & Start Tracking

final locationService = LocationPro();

// Start live GPS tracking
locationService.startTracking();

// Optional: Track a specific LatLng without live GPS
// locationService.startTracking(LatLng(23.8103, 90.4125));

// Listen to live location updates
locationService.currentLocation.addListener(() {
  print("πŸ“ Current: ${locationService.currentLocation.value}");
});

// Listen to place name updates
locationService.placeName.addListener(() {
  print("🏠 Address: ${locationService.placeName.value}");
});

Fetch Address in Specific Language

// Example: Bangla
await locationService.getPlaceName(23.8103, 90.4125, langCode: 'bn');

// Example: Japanese
await locationService.getPlaceName(35.6895, 139.6917, langCode: 'ja');

// Example: Chinese
await locationService.getPlaceName(31.2304, 121.4737, langCode: 'zh-CN');

langCode follows the IETF language tag format.


Stop Tracking

locationService.stopTracking();

Manually Fetch Current Location

await locationService.fetchCurrentLocation();
print("πŸ“ Location: ${locationService.currentLocation.value}");
print("🏠 Address: ${locationService.placeName.value}");

πŸ“Œ API Reference

Method / Property Type Description
startTracking([LatLng?]) void Starts live GPS tracking (mobile) or periodic updates (web/desktop). Can optionally provide a LatLng.
stopTracking() void Stops tracking & cancels subscriptions.
fetchCurrentLocation() Future<void> Fetches the current location & address once.
getPlaceName(lat, lng, {langCode}) Future<void> Fetches address for given coordinates in specified language.
currentLocation ValueNotifier<LatLng?> Exposes the current latitude/longitude.
placeName ValueNotifier<String> Exposes the resolved human-readable address.
_isMobile() bool Returns true if running on Android/iOS.

πŸ”‘ Permissions Setup

Android

Add the following permissions to AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

iOS

Add this to ios/Runner/Info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs your location to provide tracking features.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs your location to provide tracking features.</string>

πŸ“· Example Output

βœ… Current location: LatLng(23.8103, 90.4125)
πŸ“ Address (English): Dhaka, Bangladesh
πŸ“ Address (Bangla): ঒াকা, বাংলাদেঢ
πŸ“ Address (Japanese): ダッカ、バングラデシγƒ₯
πŸ“ Address (Chinese): 达卑, ε­ŸεŠ ζ‹‰ε›½

🧩 Flutter Example Page

import 'package:flutter/material.dart';
import 'package:location_pro/location_pro.dart';

class LocationPage extends StatefulWidget {
  final LatLng? latLng;
  const LocationPage({super.key, this.latLng});

  @override
  State<LocationPage> createState() => _LocationPageState();
}

class _LocationPageState extends State<LocationPage> {
  final LocationPro locationService = LocationPro();

  @override
  void initState() {
    super.initState();
    locationService.startTracking(widget.latLng);
  }

  @override
  void dispose() {
    locationService.stopTracking();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Location Pro Example")),
      body: Center(
        child: ValueListenableBuilder<String>(
          valueListenable: locationService.placeName,
          builder: (context, address, _) {
            return Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                ValueListenableBuilder<LatLng?>(
                  valueListenable: locationService.currentLocation,
                  builder: (context, position, _) {
                    return Text(
                      position != null
                          ? "Lat: ${position.latitude}, Lng: ${position.longitude}"
                          : "Fetching location...",
                      style: const TextStyle(fontSize: 16),
                    );
                  },
                ),
                const SizedBox(height: 10),
                Text(
                  address.isNotEmpty ? address : "Fetching address...",
                  textAlign: TextAlign.center,
                  style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
                ),
              ],
            );
          },
        ),
      ),
    );
  }
}

πŸ‘¨β€πŸ’» Developed By

Md. Abdullah Al Siddik


πŸ’‘ Contributing

Contributions are welcome!

  1. Fork the repo
  2. Create your feature branch
  3. Commit your changes
  4. Open a Pull Request

❀️ Support

If you like this package, give it a ⭐ on GitHub and share it!


I can also create a shorter β€œOne-page Quick Start” version of this README for GitHub so it’s more readable and beginner-friendly.

Do you want me to do that?

Libraries

location_pro