I am trying to track user's speed and other gps data using location package. Whenever user click on start trip button I am calling this method.
Future<void> _listenLocation(store) async {
print('listen 1');
location.changeSettings(
accuracy: LocationAccuracy.high, distanceFilter: 20, interval: 5000);
_locationSubscription =
location.onLocationChanged.handleError((dynamic err) {
setState(() {
_error = err.code;
});
_locationSubscription.cancel();
}).listen((LocationData currentLocation) {
print('listen 2');
setState(() {
print('listen 3');
_error = null;
_location = currentLocation;
print('_location');
print(_location.speed);
print(currentLocation.speed);
});
});
}
I am getting data in listen only when user is moving or coordinates are changing. How can I get data even when user is not moving ?