buildQueryAutocompleteUrl method

String buildQueryAutocompleteUrl({
  1. required String input,
  2. num? offset,
  3. Location? location,
  4. num? radius,
  5. String? language,
})

Implementation

String buildQueryAutocompleteUrl({
  required String input,
  num? offset,
  Location? location,
  num? radius,
  String? language,
}) {
  final params = <String, String>{
    'input': input,
  };

  if (language != null) {
    params['language'] = language;
  }

  if (location != null) {
    params['location'] = location.toString();
  }

  if (radius != null) {
    params['radius'] = radius.toString();
  }

  if (offset != null) {
    params['offset'] = offset.toString();
  }

  if (apiKey != null) {
    params['key'] = apiKey!;
  }

  return url
      .replace(
        path: '${url.path}$_queryAutocompleteUrl',
        queryParameters: params,
      )
      .toString();
}