how to automatically display search results in SearchDelegate without pressing enter button on keyboard, in buildResult method?

I am using SearchDelegate, i need buildResult method to happen automatically on text input, how can i do that?

  @override
  Widget buildResults(BuildContext context) {
    return FutureBuilder<Search?>(
        future: Func.searchProducts(query),
        builder: (context, snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting) {
            return buildCatalogShimmer();
          } else if (snapshot.hasData) {
            final search = snapshot.data!;
            print('работаю');
            return BuildSearchItems(search);
          } else {
            print(snapshot.error);
            return const Text("No widget to build");
          }
        }
    );
  }

>Solution :

There’s another function called buildSuggestions, which is automatically showing whenever the key word changes.

You can move your business logic from buildResult into buildSuggestions instead.

Leave a Reply