Make LocationData.accuracy and LocationData.time non-nullable - #1102
Open
matasb-google wants to merge 2 commits into
Open
Make LocationData.accuracy and LocationData.time non-nullable#1102matasb-google wants to merge 2 commits into
matasb-google wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the LocationData model in location_platform_interface to guarantee accuracy and time are always present (non-nullable), aligning behavior across platform implementations and updating Linux to populate time from GeoClue2.
Changes:
- Make
LocationData.accuracyandLocationData.timenon-nullable and update their parsing/docs inLocationData.fromMap/fromJson. - Update Linux implementation to map GeoClue2
Timestampintotime(ms since epoch). - Update package tests to include
accuracyandtimein mockedLocationDatainputs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/location/test/location_test.dart | Updates mock LocationData.fromMap inputs to include required accuracy and time. |
| packages/location/linux/location_plugin.cc | Populates time from GeoClue2 Timestamp (seconds + microseconds → ms). |
| packages/location_platform_interface/test/types_test.dart | Updates LocationData serialization/parsing tests to include accuracy and time. |
| packages/location_platform_interface/test/method_channel_location_test.dart | Updates method-channel test stubs/stream events to include required accuracy and time. |
| packages/location_platform_interface/lib/src/types.dart | Makes accuracy/time non-nullable in LocationData and updates JSON/map parsing and docs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes
LocationData.accuracyandLocationData.timenon-nullable (doubleinstead ofdouble?).Every platform implementation now consistently provides both values:
Location.getAccuracy()andLocation.getTime()).CLLocation.horizontalAccuracyandCLLocation.timestamp).GeolocationCoordinates.accuracyandGeolocationPosition.timestamp).Geocoordinate.AccuracyandGeocoordinate.Timestamp).time(derived from GeoClue2Timestampproperty). Previously,timewas omitted on Linux (resulting innullin Dart).As a result,
accuracyandtimeare now guaranteed to be present inLocationData.💥 Breaking Change
This is a breaking change for:
LocationData.fromMaporLocationData.fromJsonwho omitaccuracyortimein the map/json.LocationDatawithout these fields.All package tests have been updated to include these fields in mock data.