buildNearbySearchUrl method
String
buildNearbySearchUrl({
- Location? location,
- num? radius,
- String? type,
- String? keyword,
- String? language,
- PriceLevel? minprice,
- PriceLevel? maxprice,
- String? name,
- String? rankby,
- String? pagetoken,
Implementation
String buildNearbySearchUrl({
Location? location,
num? radius,
String? type,
String? keyword,
String? language,
PriceLevel? minprice,
PriceLevel? maxprice,
String? name,
String? rankby,
String? pagetoken,
}) {
if (radius != null && rankby != null) {
throw ArgumentError(
"'rankby' must not be included if 'radius' is specified.");
}
if (rankby == 'distance' &&
keyword == null &&
type == null &&
name == null) {
throw ArgumentError(
"If 'rankby=distance' is specified, then one or more of 'keyword', 'name', or 'type' is required.");
}
final params = <String, String>{};
if (location != null) {
params['location'] = location.toString();
}
if (keyword != null) {
params['keyword'] = keyword;
}
if (name != null) {
params['name'] = name;
}
if (rankby != null) {
params['rankby'] = rankby;
}
if (minprice != null) {
params['minprice'] = minprice.index.toString();
}
if (maxprice != null) {
params['maxprice'] = maxprice.index.toString();
}
if (type != null) {
params['type'] = type;
}
if (pagetoken != null) {
params['pagetoken'] = pagetoken;
}
if (language != null) {
params['language'] = language;
}
if (radius != null) {
params['radius'] = radius.toString();
}
if (apiKey != null) {
params['key'] = apiKey!;
}
return url
.replace(
path: '${url.path}$_nearbySearchUrl',
queryParameters: params,
)
.toString();
}