-1

I'm trying to get city name from coordinates using flutter geocoding library, but it give output in form of "Instance of 'Future'" instead of city name. Code in the screenshot. please help me here.

Screenshot with code

i'm trying to get solution from this issue.

  • Post code that people can copy+paste to reproduce your problem, not screenshots of code. Also, see [What is a Future and how do I use it?](https://stackoverflow.com/questions/63017280/) and the [Dart asynchronous programming codelab](https://dart.dev/codelabs/async-await). – jamesdlin May 13 '23 at 05:28

1 Answers1

0

For example, you can use await like this:

String cityName = await GeocodingPlatform.instance.placemarkFromCoordinates(latitude, longitude).then((value) => value.first.locality);

Or you can use then like this:

GeocodingPlatform.instance.placemarkFromCoordinates(latitude, longitude).then((value) {
  String cityName = value.first.locality;
  // do something with cityName
});
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Hari pootar
  • 147
  • 3