nearbySearch method

Future<Response<PlacesNearbySearchResponse>> nearbySearch(
  1. String location, {
  2. String? keyword,
  3. String? maxprice,
  4. String? minprice,
  5. String? name,
  6. bool? opennow,
  7. String? pagetoken,
  8. String? rankby,
  9. num? radius,
  10. String? type,
  11. String? language,
  12. CancelToken? cancelToken,
  13. Map<String, dynamic>? headers,
  14. Map<String, dynamic>? extra,
  15. ValidateStatus? validateStatus,
  16. ProgressCallback? onSendProgress,
  17. ProgressCallback? onReceiveProgress,
})

A Nearby Search lets you search for places within a specified area. You can refine your search request by supplying keywords or specifying the type of place you are searching for.

Implementation

Future<Response<PlacesNearbySearchResponse>> nearbySearch(
  String location, {
  String? keyword,
  String? maxprice,
  String? minprice,
  String? name,
  bool? opennow,
  String? pagetoken,
  String? rankby,
  num? radius,
  String? type,
  String? language,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _request = RequestOptions(
    path: r'/maps/api/place/nearbysearch/json',
    method: 'GET',
    headers: <String, dynamic>{
      ...?headers,
    },
    queryParameters: <String, dynamic>{
      if (keyword != null) r'keyword': keyword,
      r'location': location,
      if (maxprice != null) r'maxprice': maxprice,
      if (minprice != null) r'minprice': minprice,
      if (name != null) r'name': name,
      if (opennow != null) r'opennow': opennow,
      if (pagetoken != null) r'pagetoken': pagetoken,
      if (rankby != null) r'rankby': rankby,
      if (radius != null) r'radius': radius,
      if (type != null) r'type': type,
      if (language != null) r'language': language,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[
        {
          'type': 'apiKey',
          'name': 'ApiKeyAuth',
          'keyName': 'key',
          'where': 'query',
        },
      ],
      ...?extra,
    },
    validateStatus: validateStatus,
    contentType: 'application/json',
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  dynamic _bodyData;

  final _response = await _dio.request<dynamic>(
    _request.path,
    data: _bodyData,
    options: Options(
      method: _request.method,
      sendTimeout: _request.sendTimeout,
      receiveTimeout: _request.receiveTimeout,
      extra: _request.extra,
      headers: _request.headers,
      responseType: _request.responseType,
      contentType: _request.contentType,
      validateStatus: _request.validateStatus,
      receiveDataWhenStatusError: _request.receiveDataWhenStatusError,
      followRedirects: _request.followRedirects,
      maxRedirects: _request.maxRedirects,
      requestEncoder: _request.requestEncoder,
      listFormat: _request.listFormat,
    ),
  );

  const _responseType = FullType(PlacesNearbySearchResponse);
  final _responseData = _serializers.deserialize(
    _response.data,
    specifiedType: _responseType,
  ) as PlacesNearbySearchResponse?;

  return Response<PlacesNearbySearchResponse>(
    data: _responseData,
    headers: _response.headers,
    isRedirect: _response.isRedirect,
    requestOptions: _response.requestOptions,
    redirects: _response.redirects,
    statusCode: _response.statusCode,
    statusMessage: _response.statusMessage,
    extra: _response.extra,
  );
}