Skip to content
Justice Tech School

Futures and async/await

A Future is a value available later. async and await write it like normal code.

Example
Future<int> load() async {
  await Future.delayed(Duration(milliseconds: 10));
  return 42;
}
void main() async {
  print(await load());
  var all = await Future.wait([load(), load()]);
  print(all);
}

Exercise

Wait for a future.

 load()

Quiz Test

What does a Future represent?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.