Challenge

Test your knowledge of asynchronous operations.

Challenge #1

Use async/await to fetch a result from the calculateSquare(int num) API.

// Assume this function takes long time to return in real-world.
int getSquare(int num) {
  return num * num;
}

// This is the asynchronous function that makes the expensive
// data call and returns the results.
Future<int> calculateSquare(int num) async {
  return await getSquare(num);
}

Try it yourself

Solve the challenge in the code editor provided below:

Get hands-on with 1400+ tech skills courses.