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

β¨ 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:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
π iOS
Update your Info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to show relevant data</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>We need your location even when the app is in the background</string>
ποΈ 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<Placemark> 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