changed GPS listener
This commit is contained in:
@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:rogapp/widgets/debug_widget.dart';
|
||||
|
||||
class LocationController extends GetxController {
|
||||
// Reactive variable to hold the current position
|
||||
@ -97,20 +98,29 @@ class LocationController extends GetxController {
|
||||
}
|
||||
|
||||
// Set up the location options
|
||||
const locationOptions = LocationSettings(
|
||||
accuracy: LocationAccuracy.bestForNavigation,
|
||||
distanceFilter: 0,
|
||||
timeLimit: Duration(microseconds: 2500),
|
||||
);
|
||||
const locationOptions =
|
||||
LocationSettings(accuracy: LocationAccuracy.high, distanceFilter: 10);
|
||||
|
||||
// Start listening to the position stream
|
||||
positionStream =
|
||||
Geolocator.getPositionStream(locationSettings: locationOptions).listen(
|
||||
(Position position) {
|
||||
// positionStream =
|
||||
// Geolocator.getPositionStream(locationSettings: locationOptions).listen(
|
||||
// (Position position) {
|
||||
// currentPosition.value = position;
|
||||
// }, onError: (e) {
|
||||
// // Handle errors or exceptions in the stream
|
||||
// // You might want to log this error or use a state to show error messages
|
||||
// });
|
||||
|
||||
StreamSubscription<Position> positionStream =
|
||||
Geolocator.getPositionStream(locationSettings: locationOptions)
|
||||
.listen((Position? position) {
|
||||
// print(position == null
|
||||
// ? 'Unknown'
|
||||
// : '${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||
currentPosition.value = position;
|
||||
}, onError: (e) {
|
||||
// Handle errors or exceptions in the stream
|
||||
// You might want to log this error or use a state to show error messages
|
||||
|
||||
// LogManager().addLog(
|
||||
// "GPS : ${position!.latitude.toString()}, ${position.longitude.toString()} - ${DateTime.now().hour}:${DateTime.now().minute}:${DateTime.now().second}:${DateTime.now().microsecond}");
|
||||
});
|
||||
|
||||
// Resume stream if it was paused previously
|
||||
|
||||
Reference in New Issue
Block a user