getPlaceDetails method

Future<PlacesDetailsResponse> getPlaceDetails({
  1. required String placeId,
  2. String? language,
  3. String? region,
  4. String? sessionToken,
})

Once you have a place_id from a Place Search, you can request more details about a particular establishment or point of interest by initiating a Place Details request. A Place Details request returns more comprehensive information about the indicated place such as its complete address, phone number, user rating and reviews.

Implementation

Future<PlacesDetailsResponse> getPlaceDetails({
  required String placeId,
  String? language,
  String? region,
  String? sessionToken,
}) async {
  final qp = <String, dynamic>{
    'place_id': placeId,
    if (language != null) 'language': language,
    if (region != null) 'region': region,
    'sessiontoken': sessionToken ?? generateSessionToken(),
  };

  try {
    final data = await doGet(
      path: '/maps/api/place/details/json',
      params: qp,
    );

    return PlacesDetailsResponse.fromMap(data);
  } catch (error, sta) {
    print(error);
    print(sta);
    final gr = PlacesDetailsResponse.fromError(error.toString());
    return gr;
  }
}