buildFullAddressFromLatLong function
Implementation
Future<String> buildFullAddressFromLatLong(
double latitude, double longitude) async {
List<Placemark> placeMark =
await placemarkFromCoordinates(latitude, longitude).catchError((e) async {
log(e);
throw errorSomethingWentWrong;
});
// setValue(LATITUDE, latitude);
// setValue(LONGITUDE, longitude);
addPhotoStore.setAddress(Prediction(
lat: latitude.toString().validate(),
lng: longitude.toString().validate()));
Placemark place = placeMark[0];
log(place.toJson());
String address = '';
if (!place.name.isEmptyOrNull &&
!place.street.isEmptyOrNull &&
place.name != place.street) address = '${place.name.validate()}, ';
if (!place.street.isEmptyOrNull) {
address = '$address${place.street.validate()}';
}
if (!place.locality.isEmptyOrNull) {
address = '$address, ${place.locality.validate()}';
}
if (!place.administrativeArea.isEmptyOrNull) {
address = '$address, ${place.administrativeArea.validate()}';
}
if (!place.postalCode.isEmptyOrNull) {
address = '$address, ${place.postalCode.validate()}';
}
if (!place.country.isEmptyOrNull) {
address = "$address, ${place.country.validate()}";
}
setValue(ADDRESS, address);
return address;
}