title: Wait for future to complete
body: <p>I use my postgres database query to determine my next action. And I need to wait for the results before I can execute the next line of code. Now my <code>conn.query</code> returns a Future but I can't manage to get it async when I place my code in another function.</p>
  
  
  
  <pre class="lang-dart prettyprint-override"><code>main() {
    // get the database connection string from the settings.ini in the project root folder 
    db = getdb();
    geturl().then((String url) =&gt; print(url));
  }
  
  Future geturl() {
    connect(db).then((conn) {
      conn.query("select trim(url) from crawler.crawls where content IS NULL").toList()
        .then((result) { return result[0].toString(); })
        .catchError((err) =&gt; print('Query error: $err'))
        .whenComplete(() {
          conn.close();
        });
    });
  }
  </code></pre>
  
  <p>I just want <code>geturl()</code> to wait for the returned value but whatever I do; it fires immediately. Can anyone point me a of a piece of the docs that explains what I am missing here?</p>