import 'dart:async'; import 'dart:io'; void main() { print('start'); Future.delayed(Duration(seconds: 3), () { print('延迟任务'); }); Future(() { sleep(Duration(seconds: 5)); print('耗时任务'); }); print('stop'); //执行结果: // start // stop // 耗时任务 // 延迟任务 }
dart笔记12:Future.delayed延迟任务
dart笔记12:Future.delayed延迟任务:延迟任务比eventTask执行级别还低。microTask>eventTask>delayed