updateOverlay method

void updateOverlay([
  1. String? query
])

Implementation

void updateOverlay([String? query]) {
  if (listSuggestionsEntry == null) {
    final Size textFieldSize = (context.findRenderObject() as RenderBox).size;
    final width = textFieldSize.width;
    final height = textFieldSize.height;
    listSuggestionsEntry = new OverlayEntry(builder: (context) {
      return new Positioned(
          width: width,
          child: CompositedTransformFollower(
              link: _layerLink,
              showWhenUnlinked: false,
              offset: Offset(0.0, height),
              child: new SizedBox(
                  width: width,
                  child: new Card(
                      child: new Column(
                        children: filteredSuggestions.map((suggestion) {
                          return new Row(children: [
                            new Expanded(
                                child: new InkWell(
                                    child: itemBuilder!(context, suggestion),
                                    onTap: () {
                                      setState(() {
                                        if (submitOnSuggestionTap) {
                                          String newText = suggestion.toString();
                                          textField!.controller!.text = newText;
                                          textField!.focusNode!.unfocus();
                                          itemSubmitted!(suggestion);
                                          if (clearOnSubmit) {
                                            clear();
                                          }
                                        } else {
                                          String newText = suggestion.toString();
                                          textField!.controller!.text = newText;
                                          textChanged!(newText);
                                        }
                                      });
                                    }))
                          ]);
                        }).toList(),
                      )))));
    });
    Overlay.of(context)!.insert(listSuggestionsEntry!);
  }

  filteredSuggestions = getSuggestions(
      suggestions, itemSorter, itemFilter, suggestionsAmount, query);

  listSuggestionsEntry!.markNeedsBuild();
}