beginSearch method

void beginSearch(
  1. dynamic context
)

Initializes the search bar.

This adds a route that listens for onRemove (and stops the search when that happens), and then calls setState to rebuild and start the search.

Implementation

void beginSearch(context) {
  ModalRoute.of(context)!.addLocalHistoryEntry(LocalHistoryEntry(onRemove: () {
    setState(() {
      isSearching.value = false;
    });
  }));

  setState(() {
    isSearching.value = true;
  });
}