getPlaces method
Future<ApiResponse<List<MapBoxPlace> > >
getPlaces(
- String queryText, {
- @Deprecated('Use `proximity` instead, if `proximity` value is passed then it will be used and this value will be ignored') Location? location,
- Proximity proximity = const NoProximity(),
Get the places for the given query text
Implementation
Future<ApiResponse<List<MapBoxPlace>>> getPlaces(
String queryText, {
@Deprecated(
'Use `proximity` instead, if `proximity` value is passed then it will be used and this value will be ignored')
Location? location,
Proximity proximity = const NoProximity(),
}) async {
if (proximity is! LocationProximity) {
proximity =
location != null ? Proximity.Location(location) : const NoProximity();
}
final uri = _createUrl(queryText, proximity);
final response = await http.get(uri);
if (response.statusCode != 200) {
return (
success: null,
failure: FailureResponse.fromJson(json.decode(response.body))
);
}
return (
success: Predictions.fromJson(json.decode(response.body)).features,
failure: null
);
}