searchPlace method
Begins the search process by displaying a "wait" overlay then proceeds to fetch the autocomplete list. The bottom "dialog" is hidden so as to give more room and better experience for the autocomplete list overlay.
Implementation
void searchPlace(String place) {
// on keyboard dismissal, the search was being triggered again
// this is to cap that.
if (place == this.previousSearchTerm) {
return;
}
previousSearchTerm = place;
if (context == null) {
return;
}
clearOverlay();
setState(() {
hasSearchTerm = place.length > 0;
});
if (place.length < 1) {
return;
}
final RenderBox? renderBox = context.findRenderObject() as RenderBox?;
final size = renderBox?.size;
final RenderBox? appBarBox =
this.appBarKey.currentContext?.findRenderObject() as RenderBox?;
this.overlayEntry = OverlayEntry(
builder: (context) => Positioned(
top: appBarBox?.size.height,
width: size?.width,
child: Material(
elevation: 1,
child: Container(
padding: EdgeInsets.symmetric(vertical: 16, horizontal: 24),
child: Row(
children: <Widget>[
SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(strokeWidth: 3)),
SizedBox(width: 24),
Expanded(
child: Text(widget.localizationItem!.findingPlace,
style: TextStyle(fontSize: 16)))
],
),
),
),
),
);
Overlay.of(context)?.insert(this.overlayEntry!);
autoCompleteSearch(place);
}