searchByText method
Future<SearchByTextResponse>
searchByText(
- String textQuery, {
- required List<
PlaceField> fields, - String? includedType,
- int? maxResultCount,
- LatLngBounds? locationBias,
- LatLngBounds? locationRestriction,
- double? minRating,
- bool? openNow,
- List<
PriceLevel> ? priceLevels, - TextSearchRankPreference? rankPreference,
- String? regionCode,
- bool? strictTypeFiltering,
override
Fetches places based on an ambiguous text query.
Only the requested fields will be returned. If none specified,
all fields will be returned.
Note that different fields can incur different billing.
For more info about billing: https://developers.google.com/maps/documentation/places/android-sdk/usage-and-billing#pricing-new
For more info on text search: https://developers.google.com/maps/documentation/places/android-sdk/text-search
Implementation
@override
Future<inter.SearchByTextResponse> searchByText(
String textQuery, {
required List<inter.PlaceField> fields,
String? includedType,
int? maxResultCount,
inter.LatLngBounds? locationBias,
inter.LatLngBounds? locationRestriction,
double? minRating,
bool? openNow,
List<inter.PriceLevel>? priceLevels,
inter.TextSearchRankPreference? rankPreference,
String? regionCode,
bool? strictTypeFiltering,
}) async {
await _completer;
final request = SearchByTextRequest(
textQuery: textQuery,
fields: _mapFields(fields),
includedType: includedType,
maxResultCount: maxResultCount,
locationBias: locationBias != null
? _boundsToWeb(locationBias) as JSAny
: null,
locationRestriction: locationRestriction != null
? _boundsToWebLiteral(locationRestriction)
: null,
minRating: minRating,
isOpenNow: openNow,
priceLevels: priceLevels
?.map(_interPriceLevelToWebPriceLevel)
.nonNulls
.toList(growable: false)
.toJS,
rankPreference: _mapTextRankPreference(rankPreference),
region: regionCode,
language: _language,
useStrictTypeFiltering: strictTypeFiltering,
);
final prom = places.Place.searchByText(request) as JSPromise<JSObject>?;
final result = await prom?.toDart;
final response = result as ext.SearchPlacesResponse?;
final resultPlaces =
response?.places.map(_parsePlace).nonNulls.toList(growable: false) ??
[];
return inter.SearchByTextResponse(resultPlaces);
}