getPlaceDetail static method

Future<Place?> getPlaceDetail(
  1. String placeId,
  2. String mapsKey, {
  3. String? otherOptions,
})

Implementation

static Future<Place?> getPlaceDetail(String placeId, String mapsKey,
    {String? otherOptions}) async {
  /// referenceUrl = https://developers.google.com/maps/documentation/places/web-service/place-id
  // https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJrTLr-GyuEmsRBfy61i59si0&key=YOUR_API_KEY
  String mapOptions =
      ['place_id=$placeId', 'key=$mapsKey', otherOptions].join('&');

  http.Response response = await http.get(Uri.parse(
      "https://maps.googleapis.com/maps/api/place/details/json?$mapOptions"));
  debugPrint(response.body.toString());
  if (response.statusCode == 200) {
    return placeFromJson(response.body);
  } else {
    debugPrint(response.statusCode.toString());
  }
  return null;
}