当前位置:网站首页>Dart: use async and await in the loop
Dart: use async and await in the loop
2022-04-22 23:04:00 【Big front end Tour】
Dart: Use... In a loop Async and Await

stay Dart( as well as Flutter) in , You can use Future.forEach Perform synchronization operations sequentially in the loop . The following example program will print from 1 To 10 The number of . Print one number at a time , It will wait 3 second , Then print the next number .
// Big front end tour
void main() async {
final items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
await Future.forEach(items, (item) async {
print(item);
await Future.delayed(const Duration(seconds: 3));
});
}
Another way is to use... In grammar for … , As shown below :
// Big front end tour
void main() async {
final items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
for (int item in items) {
print(item);
await Future.delayed(const Duration(seconds: 3));
}
}
版权声明
本文为[Big front end Tour]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222241017548.html
边栏推荐
- MySQL日志保留策略:设置binlog日志保存天数、文件大小限制
- 【Vmware】Vmware ESXI 6.7 安装
- 基于51单片机的自动浇花系统
- [reproduction of thesis code] errors encountered in the translation embeddings for modeling multi relational data
- Minio基本使用与原理
- 【板栗糖GIS】编程的本质—(视频笔记)
- RPC详解
- 登录功能&新增文章功能的测试点提取以及测试用例编写
- SystemVerilog 验证-测试平台编写指南学习笔记(0):验证导论
- 如何看待、快手、知乎等平台将上线显示用户IP属地功能?
猜你喜欢

如何看待、快手、知乎等平台将上线显示用户IP属地功能?

.net 6 在退出构造函数时,不可为 null 的 属性“xxx”必须包含非 null 值。

C add log4net log (console and file) to console application

How does alicloud server hide real IP

加密模式介绍(ECB、CBC、PCBC、CFB、OFB、CTR)

防ddos攻击转发IP,棋牌游戏高防IP好用吗?

减治思想——二分查找详细总结

SQL语言详解

Unity uses newtonsoft JSON plug-in realizes the conversion of XML and JSON data

Minio基本使用与原理
随机推荐
3. 源码
External interrupt ------------ stm32f407zet6
CISSP认证每日知识点(2022年4月22日)
续集:几句简单,但很有用的话
抖音商品详情
Canal使用流程、部署安装文档
Difference between ov code signature and ev code signature certificate
从proc查询uid
Talking about constructor in detail
Cron expression
如何看待、快手、知乎等平台将上线显示用户IP属地功能?
MTP管理课者养成计划-第1天学习笔记
LeetCode 16. 最接近的三数之和(中等、数组)day13
Gorm preloading and self referencing
[HCTF 2018]admin之unicode欺骗
创建动态链接库,头文件报错expected initializer before “function name“
MySQL configuration adjustment: case insensitive
=============
Anti DDoS attack forwarding IP. Is the advanced anti IP of chess and card games easy to use?
数组取反-数组和字符串取反都行