An open API service indexing awesome lists of open source software.

https://github.com/amirbayat0/location-tracking-flutter

A simple Flutter app that fetches the user's real-time location, including latitude, longitude, city, and country, using the Geolocator package. Works on Android & iOS! 🚀
https://github.com/amirbayat0/location-tracking-flutter

app-developer dart flutter flutter-examples flutter-geocoding flutter-geolocator flutter-location location-services location-tracking real-time-location

Last synced: 7 months ago
JSON representation

A simple Flutter app that fetches the user's real-time location, including latitude, longitude, city, and country, using the Geolocator package. Works on Android & iOS! 🚀

Awesome Lists containing this project

README

          

# 🌍 Flutter User Location App
## 🚀 Get the user's real-time location (latitude, longitude, city, and country) using Flutter and the Geolocator package!

### [Watch on YouTube](https://youtu.be/_1owbJE5Zpc)
[![Main](https://img.youtube.com/vi/_1owbJE5Zpc/0.jpg)](https://www.youtube.com/watch?v=_1owbJE5Zpc)

## ✨ Features
* ✅ Fetch real-time latitude & longitude of the user.
* ✅ Convert coordinates to city, country, and full address.
* ✅ Auto-refresh location on startup & via button press.
* ✅ Cupertino-style loading indicator for a smooth UI experience.
* ✅ Works on Android, iOS, and Web.

## 🚀 Getting Started
1️⃣ Clone the repository
```
git clone https://github.com/your-username/flutter-user-location.git
cd flutter-user-location
```

2️⃣ Install dependencies
```
flutter pub get
```

3️⃣ Run the app
```
flutter run
```

## 🛠️ Setup & Permissions

📌 Android
Add the following permissions to your AndroidManifest.xml:
```

```

📌 iOS
Update your Info.plist:
```
NSLocationWhenInUseUsageDescription
We need your location to show relevant data
NSLocationAlwaysUsageDescription
We need your location even when the app is in the background
```

## 🏗️ Project Structure

```
📂 lib/
┣ 📜 main.dart // Entry point of the app
┣ 📜 final_view.dart // Main screen UI & logic
┣ 📜 location_helper.dart // Handles location fetching & processing
```

## 📜 Code Overview

🔹 Fetch User Location
```
Position position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high,
);
```

🔹 Convert Coordinates to City & Country
```
List placemarks = await placemarkFromCoordinates(
position.latitude, position.longitude,
);
```

🔹 Display Location in UI
```
setState(() {
userLocation = 'City: ${place.locality}, Country: ${place.country}';
});
```

## 📌 Contribution
Want to contribute? Feel free to fork this repo and submit a PR! 🚀

## 🏆 Show Some Love
⭐ Star this repo if you like it!🐦 Follow me on Twitter for more cool projects!

## 📜 License
This project is licensed under the MIT License.