I have a list view and an Appbar. The Appbar has a search icon on which I am calling the SearchDelegate. Following is my code for SearchDelegate

class StudentSearch extends SearchDelegate<StudentModel> {
  final Observable<StudentModel> studentModelDataList;


  List<Widget> buildActions(BuildContext context) {
    return [
          icon: Icon(Icons.clear),
          onPressed: () {
            query = "";

  Widget buildLeading(BuildContext context) {
    return IconButton(
        icon: Icon(Icons.arrow_back),
        onPressed: () {
          close(context, null);

  Widget buildResults(BuildContext context) {
    return Text(query);

  Widget buildSuggestions(BuildContext context) {
    return StreamBuilder(
        stream: studentModelDataList,
        builder: (context, AsyncSnapshot<StudentModel> snapshot) {
          if (!snapshot.hasData || snapshot.data == null) {
            return Center(
              child: CircularProgressIndicator(),

          final results = snapshot.data.studentModelData.studentData
              .where((a) => a.studName.toLowerCase().contains(query.toLowerCase()))

          if (snapshot.data != null) {
            return Refresh(
              year_id: "2",
              schoolId: "1",
              lastIndex: "0",
              disciplineId: "1",
              child: ListView.builder(
                itemBuilder: (context, int index) {
                  return ListTile(
                    onTap: (){
query = snapshot.data.studentModelData.studentData[index].studName;
                          close(context, snapshot.data);

                    title: Text(results[index].studName),
                    subtitle: Text('${results[index].studentEmail} '),
                    trailing: Column(
                      children: [
                itemCount: results.length,

What I understand from the documentation is that whenever I enter an item to be searched, the SearchDelegate first shows buildSuggestions and then buildResults. So I am trying to search by a student name and the buildSuggestions method works properly but when I click on an item of buildSuggestions, it does not show me buildresults

Solution 1: DMonkey

BuildSuggestions is meant to do just that, build a list of suggestions to whatever is typed in the search bar. The listener responds to each and every change to the Text Field state. This could be used to provide autocomplete suggestions to the user.

BuildResults is called when the user calls for the results by clicking on the "magnifying glass" button on the keyboard, or whatever is used to "submit" the results indicating that the user has finished their typing and is requesting the results of the text search.

You can see an explanation here Flutter's Search Support (The Boring Flutter Development Show, Ep. 10)

Taken from the documentation for buildResults(BuildContext context) → Widget "The results shown after the user submits a search from the search page."

Solution 2: user12202271

Try Calling the buildResults function at the ontap() session in your ListTile widget. Also call the data you want displayed by the BuildResults inside it like this

     Widget buildResults(BuildContext context,["Data you want displayed when you click 
     search"]) {
     return Text(query);

And in the suggestion area like this

 onTap: () =>

                                builder: (context) => Scaffold(
                                    appBar: AppBar(
                                        title: new Text(
                                          style: TextStyle(
                                              color: Colors.white),
                                    body: buildResults(context)),

Ofcourse this is just for an Example however you want to call the buildResults "lies in your court". This is how it works, The buildResult(context) takes the context in this case the data you are using from "final results" whether in "BuildResults(BuildContext, context)" and displays as called or used in-code like this

final results = snapshot.data.length;
            results = filteredUsers
                 .where((a) => (a.region.contains(query))
                      || a.region.contains(query)

return ListView.builder(
                        itemCount: results.length,
                         itemBuilder: (context, index) => Column(
                           crossAxisAlignment: CrossAxisAlignment.center,
                           mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                           mainAxisSize: MainAxisSize.max,
                           children: <Widget>[
              //As used in-code

So in my case "Data you want displayed when you click search"=[Results] represented like this

  Widget buildResults(BuildContext context, [results]) {
//How you want your BuildResult page to look like

Solution 3: Anandu Thampi

You can also use this code to call buildResult

onTap: () {