Here's my code

void getlocation() async {
LocationPermission per = await Geolocator.checkPermission();
if (per == LocationPermission.denied ||
    per == LocationPermission.deniedForever) {
  print("permission denied");
  LocationPermission per1 = await Geolocator.requestPermission();
} else {
  Position currentLoc = await Geolocator.getCurrentPosition(
      desiredAccuracy: LocationAccuracy.best);
  setState(() {
    long = currentLoc.longitude.toString();
    lat = currentLoc.latitude.toString();
  });
}

}

Here's the output when i return long and lat value to my screen and the value will always be the same. even i manually set the position to other places, it will go back to this position again later on output

1

There are 1 best solutions below

0
On

The Geolocator package returns the default location on your emulator. If you are using an android emulator, you can manually change the location from the emulator settings here, after which you have to open google maps on the emulator and tap on the get location button so the emulator registers this new location. Thereafter, you can go back and run your app. should have this new location you set showing up.