Shrutimahajan / Google-AutoComplete-TextField-Flutter

MIT License
28 stars 98 forks source link

Predictions don't close #13

Open sentd94 opened 2 years ago

sentd94 commented 2 years ago

When selecting a prediction, the prediction text is put into the text field. This might trigger a text change and therefore another prediction search with just 1 result matching the result from the first search.

AbdulrhmanBazrto commented 1 year ago

same happen here, did you find a solution for this?

paulobiero commented 1 year ago

I resolved this by making sure the text that is on the TextFormField should not be any of the suggested locations Just edit the google_places_flutter from dependancy level and edit line 100 from

alPredictions.addAll(subscriptionResponse.predictions!);

to

subscriptionResponse.predictions!.removeWhere((element)=> element.description==text); alPredictions.addAll(subscriptionResponse.predictions!);

This will solve this problem

hanif-simform commented 11 months ago

The thing is overlay is not removed if latlong fetch is not enabled, so here change is needed:

https://github.com/Shrutimahajan/Google-AutoComplete-TextField-Flutter/blob/4bfdeaa92eb430dbc4b944b0b0992797bcc919dc/lib/google_places_flutter.dart#L148C32-L153C49

if (!widget.isLatLngRequired){
  removeOverlay(); // added 
  return;
}