Location Provider
Source: pharmanet/lib/core/providers/location_provider.dart
Provider Reference
| Provider |
Type |
Description |
locationProvider |
StateNotifierProvider<LocationNotifier, LocationState> |
GPS position state |
LocationState
class LocationState {
final LatLng? position;
final bool isLoading;
final String? error;
}
Notifier Actions
| Method |
Description |
requestLocation() |
Request GPS permission and get position |
setLocation(LatLng) |
Manually set position (from map picker) |
clearLocation() |
Reset state |
Dependencies
geolocator — GPS positioning
geocoding — Reverse geocode (address from coordinates)
LocationService — Distance calculation, address autocomplete via MapTiler
Usage
final locationState = ref.watch(locationProvider);
final currentPosition = locationState.position;
// Nearby pharmacies use this location
final nearby = ref.watch(nearbyPharmaciesProvider);