fluttercommunity/flutter_google_places

Types filter shows no results

cedrichansen opened this issue · 8 comments

Hi,
I'm working on an application, and in it, I need to display information of gyms (which is a supported type in the places api ([https://developers.google.com/places/supported_types]). If I do not enter a type into the constructor, then I get any type of place to show up without a problem. However, as soon as I add a list ie: list : ["gym"], no results appear. I have tried using "food" or other supported types, and no results appear. I am still relatively new to using flutter, so I may be misunderstanding how this widget works.

The important snippet is below (taken from the example)

class CustomSearchScaffold extends PlacesAutocompleteWidget {
  CustomSearchScaffold()
      : super(
          apiKey: constants.apiKey,
          sessionToken: Uuid().generateV4(),
          language: "en",
          hint: "Search for gym",
         // types: ["gym"]
        );

  @override
  _CustomSearchScaffoldState createState() => _CustomSearchScaffoldState();
}
( rest of code to display autofill contents..)

Any advice on how to fix this, or get around this bug would be greatly appreciated!

Yes I have same issue with cities.

@jigarfumakiya try enabling billing on the Google API
https://developers.google.com/places/web-service/usage-and-billing

There is a $200 free service (if you don't exceed that amount you don't get charged)

@KevMorelli thanks for fast reply
I did still i am getting issues.

I see, are you using a custom code or trying the example?

Can you send me the code to check what's going on?

@KevMorelli
here is the code .

Prediction p = await PlacesAutocomplete.show(
      context: context,
      apiKey: Global.GoogleAPIKey,
      onError: onError,
      mode: Mode.overlay,
      types: ['cities'],
      language: "en",
      components: [Component(Component.country, selectedContryCode)],
    );

@jigarfumakiya
in types, write '(cities)' instead of 'cities'

@jigarfumakiya
in types, write '(cities)' instead of 'cities'

That fixed it for me

Please help mine shows no result at all

Prediction p = await PlacesAutocomplete.show(
                    context: context,
                    apiKey: apiKey,
                    language: 'en',
                    types: ['(cities)'],
                    mode: Mode.overlay,
                    components: [Component(Component.country, 'uk')]
                );