title: How to wait for the future object before proceeding in flutter?
body: <p>I am writing a code in flutter in which I am using an SQFlite database. I want to insert image widget from the assets, and I am getting the name of the image from database.</p>
  
  <pre><code>    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(title: Text("Single Line diagram"),backgroundColor: Colors.red.shade700,),
        body: SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          child: Align(
            //alignment: Alignment.center,
            child: SingleChildScrollView(
              scrollDirection: Axis.vertical,
              child: Row(
                //crossAxisAlignment: CrossAxisAlignment.center,
                children: imageList(),
              ),
            ),
          )
        ),
      );
    }
  </code></pre>
  
  <p>The above code calls imageList() for the list of images to display.</p>
  
  <pre><code>List&lt;Widget&gt; imageList(){
      List&lt;Widget&gt; singleLineImages = new List();
      List unit;
      for (int i = 0; i &lt;= widget.unitsList.length-1; i++){
        for (int j = 1; j &lt;= int.parse(widget.unitsList[i].quantity); j++){
          print("${widget.unitsList[i].bulletin}, ${widget.unitsList[i].mountType}, ${widget.unitsList[i].disconnect}");
          getfileName(widget.unitsList[i].bulletin, widget.unitsList[i].mountType, widget.unitsList[i].disconnect);
          //if(fileName != null) {
            singleLineImages.add(
                Image.asset("images/SD_Files_2100/$fileName.jpg", height: 400.0, width: 200.0,));
          //}
        }
      }
      return singleLineImages;
    }
  </code></pre>
  
  <p>I am getting the filename from getFileName() method which is using the database.</p>
  
  <pre><code>getfileName(String bulletin, String mountType, String disconnect)async {
      fileNameList = await db.getSDfileName(bulletin, disconnect, mountType);
      fileName = fileNameList[0]['FileName'];
      print("filename: $fileName");
    }
  </code></pre>
  
  <p>Now, after calling the getFileName(), the program is not waiting for the fileName and proceeding further, which takes <strong>filename as null</strong>. The filename is obtained correctly after the Image.asset code. <strong>Is there any way, so that the program waits untill it gets the proper filename?</strong></p>