fysoul17 / google_maps_place_picker

Place picker on Google Maps for Flutter
MIT License
222 stars 357 forks source link

Add autocompleteOnTrailingWhitespace parameter #55

Closed therladbsgh closed 3 years ago

therladbsgh commented 3 years ago

In reference to issue #54

Adds a autocompleteOnTrailingWhitespace parameter to PlacePicker to allow autocomplete to run even on whitespace. This defaults to false for backwards compatibility.

To reduce unnecessary API calls, a prevTermSearch is introduced in SearchProvider to compare the current term in the search bar with what is previously searched; if the only difference is whitespace, the API is not called.

fysoul17 commented 3 years ago

Thanks for your contribution.

Just one question before merging the request.

Can you give an example where the search results will defer when the only whitespace is entered at the end? If the result is always the same whether you enter the whitespace at the end or not, I don't see the reason we should put 'prevTermSearch' or even the 'autocompleteOnTrailingWhitespace' parameter.

Would be wonderful to give an example to package users in which scenario they can set 'autocompleteOnTrailingWhitespace' to true. ;)

therladbsgh commented 3 years ago

Not entirely sure what the question is, but I can provide a few example cases:

Case 1. User enters "Uber hq" without the timeout triggering inbetween.

Case 2. User enters "Uber hq " without the timeout triggering inbetween.

Case 3. User enters "Uber", enters timeout (search results), then adds a space ("uber ") then waits.

Case 4. User enters "Uber", enters timeout, then adds another term ("Uber hq "), then waits.

In essence autocompleteOnTrailingWhitespace removes any effect whitespace will have on autocomplete search while keeping the same amount of API calls. As you said before, from a UX standpoint this makes more intuitive sense.

fysoul17 commented 3 years ago

Fair enough!

Thanks for the explanation and example cases, @therladbsgh. It is more than enough to provide information on how to use the new parameter.

I will merge the request and include this to the next update of the package.