Before async/ await, which was recently added by Dart, you would write as
main() {
var result = expensiveA()
.then((_) => expensiveB())
.then((_) => expensiveC()); // the Future returned by expensiveC will be returned because `doSomethingWith` is not awaited in your code
result.then(doSomethingWith);
return result;
}
Future, then, , async .
main() async {
await expensiveA();
await expensiveB();
doSomethingWith(await expensiveC()); // doSomethingWith is not awaited
}
- , .
, async/await , , .
async , , await, await .
async await ed Future, await Future.
Future, , .