location_reader is a Flutter package designed to simplify the process of retrieving and handling location-related data. It supports features such as obtaining the current location, converting coordinates to city names or country codes, managing location permissions, and performing nearby location queries with GeoFirePoint and Firebase.
- 🌍 Get current location using
Geolocator - 🏙️ Convert latitude and longitude to city name and country code using
geocoding - 📍 Retrieve
GeoFirePointobjects for use in Firebase - 📡 Nearby location query support via
geoflutterfire2 - 🔐 Seamless location permission handling
- 💡 Clean architecture with services, repositories, use cases, and cubits
Add the following to your pubspec.yaml:
resolution: workspace
dependencies:
location_reader: ^<latest_version>Then run:
flutter pub getEnsure you call the DI registration method before using the services:
registerLocationServiceGetItDi();You can access location-related use cases like this:
final getCurrentLocation = sl<GetCurrentLocation>();
final location = await getCurrentLocation();Use LocationPicker and CountryCodeLoader widgets:
LocationPicker(
onTap: () => // pick location logic,
)CountryCodeLoader(
page: (code) => Text("Country: $code"),
)- [geolocator]
- [geocoding]
- [geoflutterfire2]
- [flutter_bloc]
- [get_it]
- [dartz]
- [json_serializable]
GetCityNameGetCountryCodeGetCurrentLocation
All of these use cases internally handle permissions, errors, and edge cases.
The LocationModel class supports JSON serialization using json_serializable.
Utilizes Either from dartz and custom IFailure/LocationError for structured error handling.
Feel free to open issues and contribute pull requests for enhancements or bug fixes.
MIT License. See LICENSE file for details.