location
10.2.0, released 8 days ago by bernos.dev
Flutter plugin to get real-time device location across platforms.
What it does
Provides a simple API to request the current location and listen to continuous location updates. Supports background mode on Android and iOS and works on web, Windows, macOS, and Linux.
AI-written summary of version 10.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- you need raw GPS/Network location on multiple platforms
- you want background location tracking while the app is alive
- you prefer a lightweight solution without map UI
Skip it when
- you need built‑in map widgets or advanced geofencing
- you require location after the app is terminated
Strengths
- cross‑platform (Android, iOS, web, desktop)
- background mode support on Android/iOS
- stream of location changes via onLocationChanged
Weaknesses
- no map UI or geofencing features
- background tracking stops when app is killed
- manual permission handling per platform
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 2
Add location permissions to AndroidManifest (ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, FOREGROUND_SERVICE, optional ACCESS_BACKGROUND_LOCATION). Add NSLocationWhenInUseUsageDescription / NSLocationAlwaysAndWhenInUseUsageDescription and UIBackgroundModes=location to iOS Info.plist. Enable App Sandbox > Location on macOS. No extra steps for web, Windows, Linux.
import 'package:location/location.dart';
Future<void> getCurrentLocation() async {
final location = Location();
if (!await location.serviceEnabled()) await location.requestService();
if (await location.hasPermission() == PermissionStatus.denied) {
await location.requestPermission();
}
final locData = await location.getLocation();
print('Lat: ${locData.latitude}, Lon: ${locData.longitude}');
}
Alternatives
Packages that do the same job and could replace location.
- geolocator
Offers similar cross‑platform location APIs with additional features like geofencing and distance calculations
97Compare - safe_device
Provides a unified, permission‑safe wrapper for device sensors including location
87Compare
Works with
Packages commonly used together with location: ones it builds on, ones built on it, and its own family.