getLocationDetails method

Future<LocationModel> getLocationDetails(
  1. LocationModel model
)

Implementation

Future<LocationModel> getLocationDetails(LocationModel model) async {
  final url =
      "https://maps.googleapis.com/maps/api/place/details/json?key=$qKey"
      "&placeid=${model.placeId}";
  final response = await http.get(Uri.parse(url));
  final json = jsonDecode(response.body);

  return LocationModel(
      latitude: json['result']['geometry']['location']['lat'],
      longitude: json['result']['geometry']['location']['lng'],
      address: json['result']['formatted_address']);
}