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');
langCodefollows 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!
- Fork the repo
- Create your feature branch
- Commit your changes
- 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?