geolocator
14.1.2, released 5 weeks ago by baseflow.com
Cross-platform plugin to access device GPS, location updates, and coordinate calculations.
What it does
Provides access to native location services across Android, iOS, macOS, Windows, Linux, and Web. Allows developers to check and request permissions, query current or last known positions, and stream continuous location updates. Also includes utility functions to calculate distance and bearing between coordinates.
AI-written summary of version 14.1.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need current GPS coordinates or continuous position tracking on mobile, desktop, or web.
- You need built-in handling for location permissions and service status checks.
- You need to calculate distance or bearing between geographic coordinates.
Skip it when
- You only need address geocoding or reverse geocoding without raw GPS data (use the dedicated geocoding package instead).
- You only need map rendering without location retrieval (use flutter_map directly).
Strengths
- Comprehensive platform support covering Android, iOS, macOS, Windows, Linux, and Web.
- Built-in permission handling and location service status queries.
- Provides both one-off location queries and continuous stream updates.
Weaknesses
- Extensive native configuration required, including Info.plist keys, manifest permissions, and background capability settings.
- Web platform has limitations such as lack of support for last-known position and app settings navigation.
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 6
Requires adding location permissions to AndroidManifest.xml (and background permissions if needed), adding usage descriptions to Info.plist on iOS/macOS, and configuring entitlements or Podfile bypass flags.
Future<Position> determinePosition() async {
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
return Future.error('Location services are disabled.');
}
LocationPermission permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
return Future.error('Location permissions are denied');
}
}
if (permission == LocationPermission.deniedForever) {
return Future.error('Location permissions are permanently denied.');
}
return await Geolocator.getCurrentPosition();
}Alternatives
Packages that do the same job and could replace geolocator.
- geocoding
Pick geocoding when you only need to convert addresses to coordinates or vice versa, as geocoding features were separated from geolocator.
91Compare - flutter_map
Pick flutter_map when you need to render and interact with map tiles rather than just fetch GPS coordinates.
90Compare
Works with
Packages commonly used together with geolocator: ones it builds on, ones built on it, and its own family.
- flutter_map_location_markerBuilt on geolocatorA flutter_map plugin for displaying the device's current location with a customizable marker.
- map_location_pickerBuilt on geolocatorGoogle Maps location picker for Flutter with Places API search and typed addresses.
- flutter_qiblahBuilt on geolocatorWidget that displays Qiblah direction using device sensors and location.
- google_maps_place_picker_mbBuilt on geolocatorA Flutter widget that lets users pick a location using Google Maps.
- place_picker_googleBuilt on geolocatorA place picker package for Google Maps fully written in Dart for Flutter.
- google_maps_drawing_toolsBuilt on geolocatorA Flutter plugin that adds drawing tools (polygons, circles, rectangles) on Google Maps, enabling users to interactively draw and edit shapes within a Flutter application.
- location_picker_flutter_mapBuilt on geolocatorFlutter location picker and place search using OpenStreetMap.
- ar_location_viewBuilt on geolocatorLocation-based augmented reality labels overlaying the camera preview for points of interest.