title: How can I make http calls inside a loop to be synchronous in dart flutter?
body: <p>How can i make the entire foreach loop to be synchronous? I am not able to remoce "async" as http is being called inside the loop.</p>
  
  <p>So there are 2 sets of http calls, the first http call gets the main data and then I am looping insde the main data's list to get the <code>venues_venue</code> field's id to call another api to obtain the child data, from the child data I am trying to push the <code>['title']['rendered']</code> back into the main data's list</p>
  
  <p>Now the issue is, since the foreach loop is async, the final list is not including the <code>['title']['rendered']</code> field</p>
  
  <pre><code>List userArtworkVenuesList;
  Future&lt;String&gt; _getUserArtworkWishList() async{
  
   //first http data retrieved
   var responseArtworksInWishList = await http.get(Uri.encodeFull(artworksApiBase+getArtworksApi));
   var convertedData = json.decode(responseArtworksInWishList.body);
  
   userArtworkVenuesList = convertedData;
  
   looping the above retrieved list to get the id of an item to call another http, then the retrieved item's data is appended to the parent's list
   countTheLoop = 0;
   convertedData.asMap().forEach((index,item) async{
  
     //print(item['custom_post_custom_fields']['venues_venue'][0]);
  
      var venueResponse = await http.get(Uri.encodeFull(specificVenueBase+item['custom_post_custom_fields']['venues_venue'][0]));
      var venueData = json.decode(venueResponse.body);
  
      // print(venueData);
      print('the index');
      print(index);
      print('the name of the venue is ');
      print(venueData[0]['title']['rendered']);
  
  
      convertedData[index]['venue_name'] = venueData[0]['title']['rendered'];
  
  
      countTheLoop++;
  
  
  
   });
  
  
    userArtworksList = convertedData; //this is where the problem is
    print(userArtworksList); //doesn't have the `venue_name` I see in the console the data is still being loaded
  
  }
  </code></pre>
  
  <p>Just wondering If I can force the foreach loop to be synchronous?</p>