buildAutocompleteUrl method
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,
})
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}$_autocompleteUrl',
queryParameters: params,
)
.toString();
}