Answers for "how to wait until a future completes before continuing"

0

how to wait until a future completes before continuing

main() {
  // get the database connection string from the settings.ini in the project root folder 
  db = getdb();
  geturl().then((String url) => print(url));
}

Future geturl() {
  return connect(db).then((conn) {
    return conn.query("select trim(url) from crawler.crawls where content IS NULL").toList()
      .then((result) { return result[0].toString(); })
      .catchError((err) => print('Query error: $err'))
      .whenComplete(() {
        conn.close();
      });
  });
}
Posted by: Guest on January-25-2022

Code answers related to "how to wait until a future completes before continuing"

Browse Popular Code Answers by Language