Search code examples
mobilegpsdartdart-html

How to get GPS location with Dart ? (mobile)


I would like to get the exact GPS location of the connected user by using the actual GPS of the phone for mobile users. Using DART.


Solution

  • You have to use getCurrentPosition or watchPosition. Note that those methods take several optional named parameters. By default, the location is not necessarly the most accurate and you have to use geolocation.getCurrentPosition(enableHighAccuracy: true) to get better precision.

    But be careful to the battery usage. Depending on the parameters you use the battery consumption will really change.