searchByText method

  1. @override
Future<SearchByTextResponse> searchByText(
  1. String textQuery, {
  2. required List<PlaceField> fields,
  3. String? includedType,
  4. int? maxResultCount,
  5. LatLngBounds? locationBias,
  6. LatLngBounds? locationRestriction,
  7. double? minRating,
  8. bool? openNow,
  9. List<PriceLevel>? priceLevels,
  10. TextSearchRankPreference? rankPreference,
  11. String? regionCode,
  12. 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);
}