import 'dart:async'; void main() { print('start'); Future task1 = Future(() { print('task1'); return 1; }); Future task2 = Future(() { print('task2'); return 2; }); Future task3 = Future(() { print('task3'); return 3; }); Future future = Future.wait([task1, task2, task3]); future.then((value) { print(value); }); print('end'); //执行结果: //start //end //task1 //task2 //task3 //[1, 2, 3] }
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!