selectSuggestion method

void selectSuggestion(
  1. T data
)

on tapping a item on the suggestions textEditingController will be updated with the string

Implementation

void selectSuggestion(T data) {
  _suggestions.value = [];
  _suggestionsStreamController.add([]);
  if (textEditingController.text.contains(" ")) {
    textEditingController.text =
        textEditingController.text.substring(0, textEditingController.text.lastIndexOf(" "));
  } else {
    textEditingController.text = "";
  }

  textEditingController.text = textEditingController.text + " " + data.toString() + " ";
  textEditingController.selection = TextSelection(
      baseOffset: textEditingController.text.length,
      extentOffset: textEditingController.text.length);
  setState(() {});
}