getAddress method

Future<String> getAddress(
  1. GeoPoint? g
)

Returns the address for a given GeoPoint. If the GeoPoint is null, an empty string is returned. Uses the geocode.maps.co API for reverse geocoding. param g The GeoPoint to get the address for. return The address as a string.

Implementation

Future<String> getAddress(GeoPoint? g) async {
  if (g == null) {
    return "";
  }
  var response = await http.get(
    Uri.parse(
      "https://geocode.maps.co/reverse?lat=${g.latitude}&lon=${g.longitude}&api_key=$_apiKey",
    ),
  );
  var js = jsonDecode(response.body);
  return js["display_name"];
}