Skip to content

Commit

Permalink
fix: use the last known position for the default devicePosition value…
Browse files Browse the repository at this point in the history
… to properly support emulated gps data too
  • Loading branch information
Carbonhell committed Dec 3, 2023
1 parent 7ff84ee commit 7119f6a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions localink_client/lib/src/widgets/map_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class MapPageState extends State<MapPage> {
accuracy: LocationAccuracy.high,
distanceFilter: 20,
);
var lastPos = await Geolocator.getLastKnownPosition();
_devicePosition = LatLng(lastPos!.latitude, lastPos!.longitude);

StreamSubscription<Position> positionStream =
Geolocator.getPositionStream(locationSettings: locationSettings)
.listen((Position? position) {
Expand Down Expand Up @@ -93,8 +96,6 @@ class MapPageState extends State<MapPage> {
child: FutureBuilder<void>(
future: setupMarkers(token),
builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
print(snapshot);
print(_devicePosition);
if (snapshot.connectionState == ConnectionState.done &&
_devicePosition != null) {
var markers = {Marker(
Expand Down

0 comments on commit 7119f6a

Please sign in to comment.