Search code examples
fluttergoogle-mapsgeolocationlocation

How to get user's location accuracy in meters?


I want to get user's location accuracy (circle's radius) in meters.

I have been searching about a day but I couldn't find any solution about this problem.

Position position = await Geolocator.getCurrentPosition(
          desiredAccuracy: LocationAccuracy.best);

//This is gives from 0-100m accuracy on Android, instead of best or high, I want to be able to pass the accuracy in meters.

How to precise the accuracy in meters?


Solution

  • Please read the documentation thoroughly before asking on SO.

    Both the geolocator and location packages provide this ability.

    The geolocator package has an accuracy property on the Position object it uses.

    final geo = Geolocator();
    final location = await geo.getCurrentPosition();
    print(location.accuracy);
    

    The location package has an accuracy property on the LocationData object it uses.

    final loc = Location();
    final locData = await loc.getLocation();
    print(locData.accuracy);