Closed therladbsgh closed 3 years ago
So, observing autocomplete_search.dart
, this seems to be an intentional decision:
if (controller.text.substring(controller.text.length - 1) == " ") {
provider.debounceTimer?.cancel();
return;
}
But I'm not sure what the rationale behind this would be -- most other applications with a map search will show results regardless of the space at the end.
One of the main reasons I made the package is to minimize the API call if possible. There are several packages (actually I found one similar to this) that provides place picking, but I noticed that there are too many unnecessary API calls which may charge me a lot of money for using the google map API. (It is quite expensive compare to other APIs)
So, you may see several other things that I put to reduce as fewer API calls as possible, like 'debounce timer', 'not performing a search when only zoom has changed', etc.. And yes, the code you found is also an intentional decision as typing whitespace (pressing space bar) means the user has an intention to type next word which means we don't need to waste API call until the user finishes typing the words.
Well, that was my basic intentions and of course, it is fair enough to say we need to provide search results whenever a user types a word in terms of UX. I will think about providing an optional parameter to skip the 'if statement' if there are more people who want this function.
Thanks for your opinion @therladbsgh.
Closing as the issue has been solved.
Describe the bug The autocomplete section will not show any results if there is trailing whitespace at the end of the query.
To Reproduce Steps to reproduce the behavior:
PlacePicker()
widgetExpected behavior Results should appear.
Screenshots Below is an example of searching with no trailing whitespace (autocomplete shows promptly):![VibrantFlamboyantGelding-size_restricted](https://user-images.githubusercontent.com/7328359/89095090-5606d700-d398-11ea-8ab6-5e261bff1ce5.gif)
Below is an example of searching with trailing whitespace (autocomplete will not show, until the whitespace is removed):
Flutter Doctor -v
Additional context Probably solvable by doing
.trim()
on the search term before using the Maps API?PlacePicker
usage: