Flutter – Is it possible to extract data from a Future without using a FutureBuilder?

FutureBuilder is just a convenient helper to get the widget tree rebuilt when a Future completes.

You can use

funcThatReturnsFuture().then((result) {
  print(result);
  setState(() {
    someVal = result;
  })
})

or

Future funcThatMakesAsyncCall() async {
  var result = await funcThatReturnsFuture();
  print(result);  
  setState(() {
    someVal = result;
  })
}

The main limitation is that you can’t return the value directly to the caller without a Future, because there is no way to get back from async execution to sync execution.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)