location 10.0.2
location: ^10.0.2 copied to clipboard
Cross-platform plugin for easy access to device's location in real-time.
10.0.2 #
๐ Bug fixes #
- Android: Respect the
android.builtInKotlinGradle property when deciding whether to apply the standalone Kotlin Gradle plugin. Previously the decision was based solely on the AGP major version, assuming AGP 9 always implies Built-in Kotlin. When a consumer disables Built-in Kotlin on AGP 9 (android.builtInKotlin=false), neither KGP nor Built-in Kotlin was applied and the top-levelkotlin { }block failed with no backing extension. The standalone plugin is now applied whenever Built-in Kotlin is not actually active (#1099).
10.0.1 #
๐ Bug fixes #
- Android: Completed the migration to Flutter's Built-in Kotlin. The plugin
now configures the Kotlin compiler through the top-level
kotlin { compilerOptions {} }DSL instead ofandroid.kotlinOptions {}, which is no longer available under AGP 9's Built-in Kotlin. Combined with the existing conditionalkotlin-androidapply, the plugin builds correctly on both AGP 8 (KGP) and AGP 9 (Built-in Kotlin) (#1095).
10.0.0 #
A major release with one breaking change (see below) plus a large batch of bug fixes and small features across every supported platform โ Android, iOS, macOS, web, Windows and Linux โ accumulated since 9.0.0. Thanks to everyone who reported issues and opened pull requests.
๐ฅ Breaking changes #
LocationData.latitudeandLocationData.longitudeare now non-nullable (doubleinstead ofdouble?). Every platform implementation always sets both, so the nullability was never load-bearing;fromMap/fromJsonnow throw instead of silently producing aLocationDatawith null coordinates if a caller (e.g. a hand-built test double) omits them (#675). This package's next release should be a major version bump.
๐ฏ Dart API #
- Added
LocationData.toJson(),LocationData.fromJson()andLocationData.copyWith(), soLocationDatacan be serialized, deserialized and copied without manual field wiring.fromJsonround-trips withtoJsonacross every field (#760). - Added
Location.isBackgroundPermissionGranted(), which reports whether the app has been granted background ("Allow all the time" / Always) location access. Call it beforeenableBackgroundModeto show an in-app rationale before sending the user to the system settings. On iOS/macOS it istrueonly for the "Always" authorization; on Android it reflects theACCESS_BACKGROUND_LOCATIONpermission on API 29+ and mirrorshasPermission()on older versions; on web it is alwaysfalse(#538). - Added
getLastKnownLocation(), which returns the most recently cachedLocationDataimmediately (ornullwhen none is available) without waiting for a fresh fix. Useful for showing an approximate position while a precise location is still being acquired (#733). Implemented on Android (FusedLocationProviderClient.getLastLocation) and iOS/macOS (CLLocationManager.location); web has no cached-location concept and returnsnull. - Added an optional
backgroundInterval(milliseconds) parameter tochangeSettings. When set, the location update interval automatically switches to this value while background mode is enabled and back tointervalwhen it is disabled. It is Android-only (Core Location exposes no equivalent on Apple platforms) and defaults tonull, preserving the current behaviour (#1011). - Fixed calling
getLocation()more than once concurrently (e.g. from twoFutureBuilders in the same build) resolving only the most recent call, on both Android and iOS/macOS; earlier ones hung forever. All pendinggetLocation()calls are now queued and resolved together with the same fix or error (#977).
๐ค Android #
- Added an optional
imageNameparameter tochangeNotificationOptions, which resolves a drawable resource (likeiconName) and displays it as the background notification's large icon. Defaults to no image, preserving the previous behavior (#856). - Added an optional
requireBackgroundPermissionparameter toenableBackgroundMode, defaulting totrue(preserving current behavior). Setting it tofalseskips theACCESS_BACKGROUND_LOCATION("Allow all the time") prompt and starts the foreground service directly on just the regular location permission โ a foreground service with the location type already retains location access while backgrounded without that stricter permission at all (#600). - Added optional
iconBytes/imageBytesparameters tochangeNotificationOptions, an alternative toiconName/imageNamefor apps that don't want to add a drawable resource to their Android project โ e.g. to render a Flutter icon to PNG bytes at runtime instead. Bytes take precedence over the resource name when both are provided (#1017). - Report
PermissionStatus.grantedLimitedwhen the user grants only approximate (coarse) location without precise (fine) location on Android 12+ (API 31+), mirroring iOS reduced accuracy. Previously this coarse-only case was reported asgranted(#736). - Fall back to the framework
LocationManageron devices without Google Play services (Huawei and other non-GMS devices), where the fused provider throwsSERVICE_INVALIDand location never worked. GMS availability is checked once; when present the fused path is unchanged, and the fallback is only engaged when Play services are absent or report a service-unavailable status (#772, #944, #1015). - Fixed
requestPermission()reportingdeniedForeveron the very first permission denial, including just dismissing the system dialog. This came fromshouldShowRequestPermissionRationale()returningfalseboth before a permission has ever been requested and once it's permanently denied, which the plugin previously treated as always meaning the latter. It now tracks whether the permission has actually been requested before and only reportsdeniedForeverin that case (#1009). - Fixed
LocationData.satelliteNumberalways reporting0. It was read fromLocation.extras' legacy"satellites"key, which only the old GPSLocationProviderAPI ever set โ theFusedLocationProviderClientthis plugin has used since the Kotlin rewrite never populates it. Now parsed from the$GPGGANMEA sentence's "Satellites Used" field instead, the same way MSL altitude already is (#808). - Fixed
onLocationChangedgiving no signal when location services were disabled while a stream was active โ it just silently stopped emitting. Both the fused provider's availability callback and the frameworkLocationManagerfallback's provider-disabled callback now error the stream, but only once the system location toggle is confirmed off, so ordinary transient signal loss (tunnels, indoors) doesn't misfire (#535). - Fixed
getLocation()hanging forever if the user cancelled the "enable location settings" resolution dialog it triggers. The cancellation handler checked the wrong pending-result field (one populated only byrequestPermission(), notgetLocation()or the stream), so it silently did nothing instead of resolving the call with an error. - Fixed
enableBackgroundMode()crashing with an unhandledForegroundServiceStartNotAllowedException(Android 12+, when the app has no qualifying foreground-launch exemption at that moment) instead of reporting a normal Dart-side error. - Fixed
serviceEnabled()discarding the real exception behind a generic"Location service status couldn't be determined"error, which made past reports of this error impossible to root-cause. The actual exception message and stack trace are now included (#1020). - Fixed the location listener (and any pending
getLocation()call) not resuming after the location service was toggled off and back on through Quick Settings or the Settings app rather than the plugin's own "enable location" dialog โ nothing previously observed that transition on the primary Google Play services code path (#926). - Fixed an unhandled
SecurityExceptioncrash from the fused location provider'srequestLocationUpdates()when a permission granted only "for this time" (Android 11+) is revoked by the OS between the permission check and the call โ now surfaced as a normalPERMISSION_DENIEDerror instead (#767). - Guarded the unconditional
kotlin-androidplugin apply behind an AGP version check, matching the pattern already used bydevice_info_plus,package_info_plusandshare_plus. AGP 9+ deprecated the standalone Kotlin Gradle Plugin in favor of its own built-in Kotlin support, and Flutter's temporary compatibility shim for that is scheduled for removal (#1048).
๐ iOS & macOS #
- Populated
LocationData.isMockon Apple platforms. On iOS 15.0+/macOS 12.0+ it reflectsCLLocation.sourceInformation.isSimulatedBySoftware; on older systems it staysfalse, as Core Location exposes no equivalent flag (#796). - Moved
CLLocationManager.locationServicesEnabled()off the main thread. Apple warns that this call can block the caller while location services start up; invoking it on the main thread triggered the "UI unresponsiveness" runtime warning and could hang the app (#782, #789, #909, #1004, #1027). It now runs on a background queue with the result delivered back on the main thread, sogetLocation,serviceEnabled,requestServiceandchangeSettingsno longer stall the UI. - Added an Apple privacy manifest (
PrivacyInfo.xcprivacy) for iOS and macOS, declaring no tracking, no collected data and no required-reason API use, as required for App Store submission (#947). - Fixed
getLocation()hanging forever when Core Location delivered fewer than three updates โ e.g. a static iOS-simulator "Custom Location" or a sparse first fix. The stale-location guard swallowed the first two updates by count; it now skips fixes by age instead, so the first fresh update always resolves the call (#798, #955, #1005, #660, #824, #657, #1013). - Exposed
LocationData.isProducedByAccessory, populated fromCLLocation.sourceInformation?.isProducedByAccessoryon iOS 15+/macOS 12+. It reports whether a fix came from a connected accessory such as an external GPS receiver, and defaults tofalseon older Apple systems and on Android/web (#914). - Fixed
getLocation()never resolving (no value, no exception) when authorization was.notDeterminedand the user denied the resulting just-in-time permission prompt. It now rejects with aPERMISSION_DENIEDerror in that case, matching the behavior when authorization is already.deniedbefore the call starts (#979). - Fixed
LocationData.speed/speedAccuracyreporting a literal-1instead ofnullfor an indoor/stationary fix. Core Location uses a negative value as its own documented sentinel for "invalid/not available"; it's now mapped tonullinstead of being passed through as if it were a real measurement (#741). - Recognized the modern
NSLocationAlwaysAndWhenInUseUsageDescriptionInfo.plistkey when deciding whether "Always" authorization can be requested. Only the pre-iOS 11NSLocationAlwaysUsageDescriptionkey was checked before, so an app declaring solely the current, README-recommended key was treated as having no always-usage description at all (#962). - Fixed
changeSettings(interval: ...)having no effect at all; the stream fired as fast as Core Location delivered fixes.intervalwas never read on iOS/macOS โ Core Location has no native time-based interval concept (onlydistanceFilter, a minimum distance) โ so it's now applied by throttling stream delivery client-side instead (#960). - Fixed
hasPermission()reporting plaindeniedfor an authorization status thatrequestPermission()already correctly reports asdeniedForever(iOS has no "denied, can ask again" state โ once authorization is.denied, the system won't show the prompt again). The two methods now agree on the same state (#738). - Fixed
getLocation()hanging forever when denied in the same authorization change as a concurrentrequestPermission()call โ only therequestPermission()side was being resolved. - Fixed
getLocation()/hasPermission()hanging or misreporting for.restrictedauthorization status (parental controls/MDM), which wasn't handled the same way as.denied.
๐ Web #
- Fixed
hasPermission()throwing on web (Failed to read the 'name' property from 'PermissionDescriptor'/ aTypeError). The Permissions API was handed an opaque boxed Dart object instead of a real JS descriptor; it now receives a proper{ name: 'geolocation' }object literal (#978, #987). - Fixed
getLocation()/onLocationChangederrors not being catchable asPlatformExceptionon web like they are on Android/iOS; browser Geolocation errors are now mapped to aPlatformExceptionwith aPERMISSION_DENIED/POSITION_UNAVAILABLE/TIMEOUTcode (#967). - Fixed
requestPermission()reportingdeniedForeverfor a location-fetch failure unrelated to permission (e.g. a GPS timeout after the user already allowed access) (#891). - Fixed
hasPermission()crashing in browsers/webviews that support Geolocation but not the Permissions API (navigator.permissionsundefined); it now reports "not yet determined" instead (#959).
๐ Docs #
- Clarified that
enableBackgroundMode(enable: true)is a standalone call that can be made before listening toonLocationChanged, and that on Android it requests theACCESS_BACKGROUND_LOCATIONpermission when needed โ so background permission can be requested independently (#756). - Documented that background mode does not survive the app being killed or
terminated by the user or OS โ neither the Android foreground service nor
the iOS background execution exemption can run once the process itself no
longer exists โ and pointed to
flutter_background_geolocationfor that use case (#707, #724, #773, #774, #888, #994, #1021, #1024, #1025). - Clarified that
pausesLocationUpdatesAutomatically(defaulttrueon iOS/macOS) can cause continuous background tracking to stop unpredictably, and that setting it tofalseviachangeSettingsavoids that for apps that need truly continuous updates. - Documented that
changeNotificationOptions'iconName/imageNameresolve drawables by name at runtime, which Android's release-build resource shrinker can strip since it can't see dynamic lookups โ and how to keep them via ares/raw/keep.xmltools:keepentry (#839). - Documented posting fully custom notification content (e.g. via
flutter_local_notifications) by reusing thechannelId/notificationIdchangeNotificationOptionsalready returns, since Android identifies the foreground service's notification purely by that ID (#753, #928).
9.0.0 #
A major maintenance release that modernises every platform and adds desktop support. Thanks to everyone who reported issues and opened pull requests.
โจ New platforms #
- Windows support, backed by the
Windows.Devices.Geolocation(WinRT) APIs. - Linux support, backed by GeoClue2 over D-Bus.
๐ค Android #
- Rewrote the plugin from Java to Kotlin.
- Moved off the deprecated
FusedLocationProviderAPI toLocationRequest.BuilderandPriority, removing the build-time deprecation warnings (#1019, #1023, #1035). - Declare
FOREGROUND_SERVICE_TYPE_LOCATIONso background location keeps working on Android 14+ (#970). - Approximate ("coarse") location grants are now honoured instead of being reported as denied (#990, #991).
- Fixed a crash on dispose when the engine had already detached (#1041).
- More reliable mock-location detection on Android 12+ (#1016).
- Toolchain bumps: Android Gradle Plugin 8.11, Kotlin 2.2, Gradle 8.14,
compileSdk/targetSdk36.
๐ iOS & macOS #
- Rewrote the plugin from Objective-C to Swift, sharing a single source across iOS and macOS.
- Added Swift Package Manager support (#1044, #1047).
- Adopted the modern authorization APIs and removed the deprecated
UIAlertView. - No longer crashes at launch when the Info.plist usage description is missing (#1040, #1042).
getLocationnow resolves when precise location is turned off (#984).
๐งน Housekeeping #
- Bumped dev dependencies (
leancode_lint,build_runner,mockito). - Fixed the example app build and migrated it to current Flutter templates.
- Documented the newly supported platforms.
โ ๏ธ Breaking changes #
- No Dart API changes โ existing code continues to work.
- Native deployment floors were raised: iOS 12, macOS 10.15, and the newer Android toolchain above.
- Android now requests both
ACCESS_FINE_LOCATIONandACCESS_COARSE_LOCATION; apps that use background location should also declareFOREGROUND_SERVICE_LOCATION.
8.0.1 #
- Bump dependency on
location_platform_interfaceto^6.0.1(#933)
8.0.0 #
- Bump minimum Dart version to 3.4, minimum Flutter version to 3.22
- Bump dependency on
package: location_webto^6.0.0- Remove dependency on
js(#1007)
- Remove dependency on
7.0.1 #
- Bump dependency on
package: location_webto^5.0.4
7.0.0 #
- Bump minimum Dart version to 3.4, minimum Flutter version to 3.22
- Bump dependencies
6.0.2 #
- Fix bugs #620 and #864 (#889)
6.0.1 #
- Downgraded location_web dependency on js ^0.7.1 to js ^0.6.3 for compatibility with firebase_core ^2.27.2 (#942)
6.0.0 #
- Bump Android Gradle Plugin from 7.4.2 to 8.3.1
- Bump minimum supported Android SDK to 21
- Bump minimum Dart version to 3.1, minimum Flutter version to 3.16
- Bump dependencies
5.0.3 #
- Lower minimum iOS deployment target from 13 to 11 (#882 by Matias de Andrea)
5.0.2+1 #
- Clean up README (#874)
- Fix broken links in the README of
locationpackage - Remove most of the duplicated info from repo's top-level README
- Fix broken links in the README of
5.0.2+1 #
- Bump dependency on
location_platform_interfaceto^3.1.1 - Bump dependency on
location_webto^4.1.1
5.0.1 #
- Refactoring (#853)
- Set up code formatting & linting on CI, and fix all warnings that arose
- Bump dependency on
location_platform_interfaceto^3.1.0 - Bump dependency on
location_webto^4.1.0 - Bump minimum Flutter to 3.3
5.0.0 #
- Fix build errors on Android (#847)
- Bump minimum Flutter to 3.0 (#847)
4.4.0 #
- FEAT: support android 12 in example app.
4.3.0 #
- FIX: fix location package test.
- FEAT: improve coverage.
4.2.3 #
- FIX: fix macos build, fixing #544.
4.2.2 #
- FIX: fix android crash on Android API 27, #579.
4.2.1 #
- FIX: add compatibility version to target Java 8.
4.2.0 #
- REFACTOR: remove Android strings.
- REFACTOR: extract background notification logic to separate class.
- FIX: wait 2 location updates to make sure that the last knwown position isn't returned instantly #549.
- FIX: fix the depreciation warning on android #550.
- FIX: improve changeSettings to be applied immediatly.
- FEAT: add several information to resolve #552.
- FEAT: add several information to resolve #552.
- FEAT: better listen example to prevent infinite location request.
- FEAT: fix typos.
- FEAT: add ios requirements.
- FEAT: improve example app.
- FEAT: separate result variables to prevent result override.
- FEAT: add isMock information on LocationData.
- FEAT: add fallback for LocationAccuracy.reduced on Android.
- FEAT: add option to reopen app from notification.
- FEAT: allow for customizing Android notification text, subtext and color.
- FEAT: update example app to showcase Android notification options.
- FEAT: allow for customizing Android background notification from dart.
- FEAT: handle notification changes in Android MethodCallHandler.
- FEAT: return notification and channel id when changing options.
- DOCS: update readme web.
- CHORE: publish packages.
- CHORE: publish packages.
- CHORE: publish packages.
- CHORE: publish packages.
- CHORE: publish packages.
4.1.1 #
- FIX: fix crash on build.
4.1.0 #
- REFACTOR: remove Android strings.
- REFACTOR: extract background notification logic to separate class.
- FEAT: add option to reopen app from notification.
- FEAT: allow for customizing Android notification text, subtext and color.
- FEAT: update example app to showcase Android notification options.
- FEAT: allow for customizing Android background notification from dart.
- FEAT: handle notification changes in Android MethodCallHandler.
- FEAT: return notification and channel id when changing options.
- DOCS: update readme web.
- CHORE: publish packages.
- CHORE: publish packages.
- CHORE: publish packages.
- CHORE: publish packages.
4.0.2 #
- Bump "location" to
4.0.2.
4.0.1 #
- DOCS: update readme web.
- CHORE: publish packages.
4.0.0 #
- FEAT: Update to null safety.
- Update to null safety and Melos
3.2.4 19th January 2021 #
- Fix crash on Android
3.2.3 19th January 2021 #
- Fix crash during close of the app
- Remove mandatory Android permission if not using the background location
3.2.1 23rd December 2020 #
- Fix crash during build
3.2.0 23rd December 2020 #
- Add the ability to launch location notifications when application is in
background
- on iOS implemented with native background location support by adding required permissions and permission checks
- on Android by providing a custom service that wraps existing native location API calls in a foreground service
- Update Android SDK to Android 10/Q (API level 29)
- Updated sample application to include the background mode
- Various bug fixing
3.1.0 09 October 2020 #
- Do not throw errors from methods that do not need an activity.
- [BREAKING] The error thrown is now ActivityNotFoundException which changes the error code returned when activity is not found. It used to be NO_ACTIVITY, now it is just error. We anticipate this error to be rarely experienced in the wild.
3.0.3 25th August 2020 #
- Add capability to return reduced accuracy permission on iOS 14.0
3.0.2 23rd April 2020 #
- Fix crashes on v1 apps.
3.0.1 27th March 2020 #
- Fix a crash happening during iOS build
3.0.0 26th March 2020 #
- Add Web and macOS as new supported platforms (huge thanks to long1eu)
- [BREAKING] Enums are now following Dart guidelines.
- [BREAKING] onLocationChanged is now a getter to follow Dart guidelines.
2.5.4 11st March 2020 #
- Update documentation
- Fix: Airplane mode was preventing location from being requested
- Fix: Not crashing when activity is not set on Android
2.5.3 26th February 2020 #
- Improve code coverage
- Update documentation
2.5.2 25th February 2020 #
- Fix crash on pre-1.12 projects
- Align PermissionStatus on iOS with Android
2.5.1 23rd February 2020 #
- Fix SDK version
2.5.0 23rd February 2020 #
- [BREAKING] The
requestPermissionandhasPermissionare now returning PermissionStatus enum. - Upgrade to Android Embedding V2 (follow https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects if the plugin isn't working after upgrade)
- Resolve getLocation when service is disabled thanks to nicowernli
- Update example app
- Fix bugs leading to non returning code
getLocationnow throws properlypub.devnow states that the plugin is not compatible with Flutter Web (yet)
2.4.0 14th February 2020 #
- Align timestamp in Android and iOS, previously the iOS timestamp was in seconds instead of milliseconds. Thanks to 781flyingdutchman.
2.3.7 08th January 2020 #
- Fix bug where requestPermission is called after the user has already denied the system location dialog, then this method call would never return.
2.3.6 07th January 2020 #
- Fix ClassCastException errors on some Android phones when requesting Location status.
2.3.5 10th April 2019 #
- Fix incompatibily with headless plugins thanks to ehhc
- Fix error with iOS when permission already given
- Add Google maps example
2.3.4 8th April 2019 #
- Fix error on Android 21 API thanks to noordawod
- Update Google API version
2.3.3 31th March 2019 #
- Align altitude on Sea Level when available on Android (matching iOS altitude).
2.3.2 27th March 2019 #
- Remove GPS limitation on Android
2.3.1 25th March 2019 #
- Fixes README
- Fixes requestPermission not responding the correct result on iOS
2.3.0 22nd March 2019 #
- Update example App with proper cancel
- Add possibility to set accuracy, interval and minimum notification ditance of the requests.
- Add LocationAccuracy object
2.2.0 19th March 2019 #
- Actually updating locatino when using getLocation (not only relying on LastLocation)
- Add timestamp to LocationData
- Add serviceEnabled method to check whether Location Service is enabled.
- Add requestService method to ask the user to activate the location service.
- Fix continuous callback heading
2.1.0 16th Match 2019 #
- iOS permission should be closer to Android permission behaviour thanks to PerrchicK
- Adding requestPermission(), to manually request permission
- Several feature fixed for less crash when using the plugin
- Code Cleanup
- Update Readme and add a warning for the location bug in iOS simulator
2.0.0 25th January 2019 #
- Code cleanup
- BREAKING CHANGE: Change Dart API to return structured data rather than a map.
1.4.0 21st August 2018 #
- Add lazy permission request thanks to yathit
- Add hasPermission() thanks to vagrantrobbie
- Bug correction thanks to jalpedersen
- Add more examples
1.3.4 4th June 2018 #
- Fix crash for Android API pre 27 thanks to matthewtsmith.
1.3.3 30th May 2018 #
- Correct implementation of iOS plugin to match Android behaviour. No need to call getLocation to get permissions for location callbacks.
1.3.2 30th May 2018 #
- Change implementation to api in build.gradle in order to solve incompatibilities between GMS versions thanks to luccascorrea
1.3.1 29th May 2018 #
- Added speed and speed_accuracy (only Android truly discover speed accuracy, so its always 0 for now on iOS)
- Solved a crash
1.3.0 27th May 2018 #
- Make it compatible with Firebase thanks to quangIO
- Resolve runtime error exception thanks to jharrison902
- Update gitignore thanks to bcko
1.2.0 5th April 2018 #
- Permissions denied on Android handled thanks to g123k
- Dart 2 update thanks to efortuna
1.1.6 19th Octobre 2017. #
- iOS code from Swift to Objective-C thanks to fluff
1.1.1 20th July 2017. #
- Fixes for iOS result's format.
1.1.0 17th July 2017. #
- Added permission check for Android 6+ (thanks netdur). Still no callback when permissions granted so aiming SDK 21 is safer.
1.0.0 7th July 2017. #
- Initial Release.



