Flutter: Determining the speed of a vehicle using GPS

Viewed 5673

I want to monitor the speed the of device(mobile,tablet,..) like google maps where they shows the speed of vehicle moving with almost exact speed with the delay of fractions of second. if it is possible please let me know.

2 Answers

Yes, you can measure the speed by using geolocator plugin. It provides you Position object and you can call speed on it. Example:

var geolocator = Geolocator();
var options = LocationOptions(accuracy: LocationAccuracy.high, distanceFilter: 10);

geolocator.getPositionStream(options).listen((position) {
  var speedInMps = position.speed; // this is your speed
});

This is the currently working implementation...

 Geolocator.getPositionStream(
        forceAndroidLocationManager: true,
        intervalDuration: Duration(seconds: 3),
        distanceFilter: 2,
        desiredAccuracy: LocationAccuracy.bestForNavigation)
    .listen((position) {
  var speedInMps =
      position.speed.toStringAsPrecision(2); // this is your speed
  print(speedInMps);
Related