location_reader 0.0.7
location_reader: ^0.0.7 copied to clipboard
A Flutter package for retrieving and handling location-related data, including current location, reverse geocoding, Firebase integration, location permission management, and nearby location queries.
location_reader #
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.
Features #
- π Get current location using
Geolocator
- ποΈ Convert latitude and longitude to city name and country code using
geocoding
- π Retrieve
GeoFirePoint
objects for use in Firebase - π‘ Nearby location query support via
geoflutterfire2
- π Seamless location permission handling
- π‘ Clean architecture with services, repositories, use cases, and cubits
Installation #
Add the following to your pubspec.yaml
:
dependencies:
location_reader: ^<latest_version>
Then run:
flutter pub get
Getting Started #
1. Register Dependencies #
Ensure you call the DI registration method before using the services:
registerLocationServiceGetItDi();
2. Use Cases #
You can access location-related use cases like this:
final getCurrentLocation = sl<GetCurrentLocation>();
final location = await getCurrentLocation();
3. UI Integration #
Use LocationPicker
and CountryCodeLoader
widgets:
LocationPicker(
onTap: () => // pick location logic,
)
CountryCodeLoader(
page: (code) => Text("Country: $code"),
)
Dependencies #
- [geolocator]
- [geocoding]
- [geoflutterfire2]
- [flutter_bloc]
- [get_it]
- [dartz]
- [json_serializable]
Example Use Cases #
GetCityName
GetCountryCode
GetCurrentLocation
All of these use cases internally handle permissions, errors, and edge cases.
JSON Support #
The LocationModel
class supports JSON serialization using json_serializable
.
Error Handling #
Utilizes Either
from dartz
and custom IFailure
/LocationError
for structured error handling.
Contributing #
Feel free to open issues and contribute pull requests for enhancements or bug fixes.
License #
MIT License. See LICENSE
file for details.