title: Showing json data upon selecting item from suggestion list
body: <p>I want to fetch and show corresponding player's data when their name is selected from the suggestion list. I have <code>AutoCompleteTextField</code> widget using which player's name is typed and selected from the list, as below:</p>
  
  <p><a href="https://i.stack.imgur.com/04Dv7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/04Dv7.png" alt="enter image description here"></a></p>
  
  <p>Current issue I am facing is, when player is searched and selected, then I get <code>null</code> value back at first, as below:</p>
  
  <p><a href="https://i.stack.imgur.com/WZBm5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WZBm5.png" alt="enter image description here"></a></p>
  
  <p>But when I tap in the search field and select the same player again from suggestion list, then the api call is made and data is shown properly, as below:</p>
  
  <p><a href="https://i.stack.imgur.com/3rdw9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3rdw9.png" alt="enter image description here"></a></p>
  
  <p>Current code is, on <code>itemSubmitted</code> parameter of <code>AutoCompleteTextfield</code>, I am making call to the method that shows the data inside <code>setState()</code>, as below:</p>
  
  <pre><code>itemSubmitted: (item) {
                    setState(() {
                      searchTextField.textField.controller.text = item.name;
                      textInput = true;
                      showData();
                    });
                  },
  </code></pre>
  
  <p>Inside <code>showData()</code>, I am parsing the json per input search in the field and if player data is found, I am making another call inside same method to fetch the data, as below:</p>
  
  <pre><code>showData() {
      String input = searchTextField.textField.controller.text.toLowerCase();
      found = false;
  
      for (var i = 0; i &lt; PlayerViewModel.players.length; i++) {
        if (PlayerViewModel.players[i].name.toLowerCase() == input) {
          players = PlayerViewModel.players[i];
          found = true;
          break;
        }
      }
      if (found) {
        fetchJson(players.pid);
      }
    }
  
    void fetchJson(int pid) async {
      var response = await http.get(
          'http://cricapi.com/api/playerStats?apikey=&lt;apiKey&gt;&amp;pid=$pid');
      if (response.statusCode == 200) {
        String responseBody = response.body;
        var responseJson = jsonDecode(responseBody);
        name = responseJson['name'];
        playingRole = responseJson['playingRole'];
        battingStyle = responseJson['battingStyle'];
        country = responseJson['country'];
        imageURL = responseJson['imageURL'];
        data = responseJson;
  </code></pre>
  
  <p>The data is fetched properly but not firing at first attempt when I select player from list, but only at second attempt when I select the player again from the list. And this happens for every subsequent player search.
  What am I missing here ? How to fetch and show the data as soon as the player name is selected from suggestion list ?</p>