getAddressFromPlacerMark static method

Future<String> getAddressFromPlacerMark(
  1. Position position
)

Implementation

static Future<String> getAddressFromPlacerMark(Position position) async {
  AppConfig.logger.t("getAddressFromPlacerMark");

  Placemark placeMark = await GeoLocatorController().getPlaceMark(position);
  String country = placeMark.country ?? "";
  String locality = placeMark.locality ?? "";
  String address = "";

  if(locality.isNotEmpty && country.isNotEmpty) {
    address = "$locality, $country";
  } else if(locality.isNotEmpty) {
    address = locality;
  } else if (country.isNotEmpty) {
    address = country;
  }

  AppConfig.logger.t(address);
  return address;
}