buildQueryAutocompleteUrl method

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

DEPRECATED

Implementation

// String buildAutocompleteUrl({
//   required String input,
//   String? sessionToken,
//   num? offset,
//   Location? origin,
//   Location? location,
//   num? radius,
//   String? language,
//   List<String> types = const [],
//   List<Component> components = const [],
//   bool strictBounds = false,
//   String? region,
// }) {
//   final params = <String, String>{
//     'input': input,
//   };
//
//   if (language != null) {
//     params['language'] = language;
//   }
//
//   if (origin != null) {
//     params['origin'] = origin.toString();
//   }
//
//   if (location != null) {
//     params['location'] = location.toString();
//   }
//
//   if (radius != null) {
//     params['radius'] = radius.toString();
//   }
//
//   if (types.isNotEmpty) {
//     params['types'] = types.join('|');
//   }
//
//   if (components.isNotEmpty) {
//     params['components'] = components.join('|');
//   }
//
//   if (strictBounds) {
//     params['strictbounds'] = strictBounds.toString();
//   }
//
//   if (offset != null) {
//     params['offset'] = offset.toString();
//   }
//
//   if (region != null) {
//     params['region'] = region;
//   }
//
//   if (apiKey != null) {
//     params['key'] = apiKey!;
//   }
//
//   if (sessionToken != null) {
//     params['sessiontoken'] = sessionToken;
//   }
//
//   return url
//       .replace(
//         path: '${url.path}${NeomMapsUrls.placesAutocompleteUrl}',
//         queryParameters: params,
//       )
//       .toString();
// }

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}${NeomMapsUrls.queryAutocompleteUrl}',
        queryParameters: params,
      )
      .toString();
}