title: Flutter | SearchDelegate | On search i have to make API after getting response i have build a widget
body: <p>I am trying to make an API call on search, and based on that I have to build a widget.</p>
  
  <p>Is this correct?</p>
  
  <pre><code>class DataSearch extends SearchDelegate&lt;Future&lt;Widget&gt;&gt; {
  
    Future serachdb(searchData) async {    
      var url = '$_globalUrl/api/searchdata';
      var param = {'searchby': searchData};
      var result = await http.post(url, body: param);
      if (result.body != '') {
        userData = json.decode(result.body);
      }
    }
  
    @override
    Widget buildResults(BuildContext context) {
      serachdb(query);  // it doesn't wait untill this completes  
      return resultContent();
    }
  
    Widget resultContent(){
      return new Scaffold(
        /*
        some code
        */
      );
    }
  }
  </code></pre>