Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. void main() async {
  2. final square3Future = square(3);
  3. final square4Future = square(4);
  4. final square3 = await square3Future;
  5. final square4 = await square4Future;
  6. int sum = square3 + square4;
  7. print('3^2 + 4^2 = $sum');
  8. }
  9.  
  10. Future<int> square(int val) async {
  11. print('${DateTime.now()} started calculating $val^2');
  12. await Future.delayed(Duration(seconds: 1));
  13. int result = val * val;
  14. print('${DateTime.now()} finished calculating $val^2');
  15. return result;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement