location_pro 1.0.3 copy "location_pro: ^1.0.3" to clipboard
location_pro: ^1.0.3 copied to clipboard

A Flutter service for real-time location tracking with reverse geocoding (address lookup) using OpenStreetMap Nominatim API. Supports Android, iOS, Web, and Desktop.

# Location Pro πŸ“

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

It supports **direct LatLng input**, allowing address fetch 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 **OpenStreetMap 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 to your `pubspec.yaml`:

```yaml
dependencies:
  location_pro: ^Latest Version

Then fetch packages:

flutter pub get

Import in your Dart file:

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 location updates
locationService.currentLocation.addListener(() {
  print("πŸ“ Current: ${locationService.currentLocation.value}");
});

// Listen to address 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 Start GPS tracking (mobile) or periodic updates (web/desktop). Optionally provide a LatLng.
stopTracking() void Stop tracking & cancel subscriptions.
fetchCurrentLocation() Future<void> Fetch current location & address once.
getPlaceName(lat, lng, {langCode}) Future<void> Fetch address for given coordinates in specified language.
currentLocation ValueNotifier<LatLng?> Exposes current latitude/longitude.
placeName ValueNotifier<String> Exposes human-readable address.
_isMobile() bool Returns true if running on Android/iOS.

πŸ”‘ Permissions Setup #

Android #

Add 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 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


❀️ Support #

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


1
likes
160
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter service for real-time location tracking with reverse geocoding (address lookup) using OpenStreetMap Nominatim API. Supports Android, iOS, Web, and Desktop.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, geolocator, http

More

Packages that depend on location_pro