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: 23 days 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! 🚀
- Host: GitHub
- URL: https://github.com/amirbayat0/location-tracking-flutter
- Owner: AmirBayat0
- License: mit
- Created: 2025-02-17T09:25:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-17T09:38:00.000Z (over 1 year ago)
- Last Synced: 2025-02-17T10:28:58.301Z (over 1 year ago)
- Topics: app-developer, dart, flutter, flutter-examples, flutter-geocoding, flutter-geolocator, flutter-location, location-services, location-tracking, real-time-location
- Language: Dart
- Homepage: https://youtu.be/_1owbJE5Zpc?si=c6zIknhEeCFnpI6k
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)
[](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.