import 'dart:io';
main(List<String> args) {
print('start');
Future((){
sleep(Duration(seconds: 3));
return "第1次的结果";
}).then((res){
print(res);
sleep(Duration(seconds: 3));
return "第2次的结果";
})..then((res){
print(res);
sleep(Duration(seconds: 3));
return "第3次的结果";
}).then((res){
print(res);
sleep(Duration(seconds: 3));
return "第4次的结果";
}).then((res){
print(res);
}).catchError((error) {
print("$error");
}).whenComplete((){
print("全部执行结束...");
});
print("end");
}
网友评论