latlong_to_place 0.0.8
latlong_to_place: ^0.0.8 copied to clipboard
A Flutter library to fetch device LatLng via geolocator and convert it into rich PlaceInfo via the null-safe geocoding plugin.
latlong_to_place #

A powerful Flutter library to handle all your geocoding, routing, and location-based needs. Convert latitude/longitude into rich PlaceInfo, calculate distances, get OSRM routes, check permissions, and more.
Features #
- πΊοΈ Reverse Geocoding: Convert
lat,lngto a structuredPlaceInfoaddress, with optional caching and accuracy controls. - π Batch Geocoding: Fetch multiple addresses in a single call.
- π¦ Location Permissions: A simple helper to check
granted,denied, andserviceDisabledstatuses. - π§ Geo-Fencing: Simple radius-based check to see if a point is inside a given area.
- π Multi-Stop Routing: Get the best route and turn-by-turn instructions for multiple waypoints via OSRM.
- π Distance Calculation: Measure distances between coordinates in KM, meters, or miles.
Installation #
Add to your appβs pubspec.yaml:
dependencies:
latlong_to_place: ^0.0.8 # Use the latest version
API Showcase #
1. Geocoding (Single, Batch & Cached) #
The GeocodingService is your entry point for all address lookups.
final _geo = GeocodingService();
// Single lookup with caching
final PlaceInfo place = await _geo.getPlaceInfo(
28.6139,
77.2090,
useCache: true,
accuracy: AccuracyMode.high,
);
print(place.formattedAddress);
// Batch lookup
final List<PlaceInfo> places = await _geo.getPlacesInfo([
LatLng(28.61, 77.20),
LatLng(28.53, 77.39),
]);
print(places.map((p) => p.city).toList());
2. Location Permission Status #
Check permissions easily before accessing location.
final LocationStatus status = await LocationService.checkStatus();
if (status == LocationStatus.granted) {
// Permission granted, proceed
} else {
// Handle denied, permanently denied, or disabled service
}
3. Multi-Stop Routing & Instructions #
Get a route for multiple waypoints, including distance, duration, and turn-by-turn instructions.
final route = await RouteService.getBestRoute(
stops: [
LatLng(28.6139, 77.2090), // Delhi
LatLng(28.5355, 77.3910), // Noida
LatLng(28.4595, 77.0266), // Gurgaon
],
mode: TravelMode.driving,
);
if (route != null) {
print('Distance: ${route.distanceKm.toStringAsFixed(2)} km');
print('Duration: ${route.duration.inMinutes} mins');
print('Instructions: ${route.instructions.first}'); // e.g., "Turn left onto..."
}
4. Geo-Fencing #
Check if a point is within a certain radius.
final bool isInside = GeoFence.isInside(
point: LatLng(28.61, 77.20),
center: LatLng(28.60, 77.19),
radiusMeters: 2000, // 2km radius
);
print('Is inside fence: $isInside');
