Chapter 11 - UX - start searching if pressed enter

Hi,
Just wanted to mention a small thing !
Currently, we call startSearch(searchTextController.text) if we press on search icon or we select an entry from dropdown.
If we can include startSearch(searchTextController.text) inside onSubmitted: of the TextField in _buildSearchCard() , then the search will be happening once we press enter on keyboard as well.

If condition can be commented or removed as it is done inside startSearch(…)

The code will look something like this finally.

onSubmitted: (value) {
  // if (!previousSearches.contains(value)) {
  //   previousSearches.add(value);
  //   savePreviousSearches();
  // }
  startSearch(searchTextController.text);
},

Thanks

1 Like