当前位置:网站首页>Flutter03-Dart异步
Flutter03-Dart异步
2022-04-22 02:48:00 【weixin_42580612】
Dart异步
Future
Dart 是一门单线程编程语言
- Future 对象封装了Dart 的异步操作,它有未完成(uncompleted)和已完成(completed)两种状态。
- completed状态也有两种:一种是代表操作成功,返回结果;另一种代表操作失败,返回错误。
1.1 then
void main(List<String> arguments) {
print('start');
Future f = getNetwort();
print(f.then((value) => print(value)).catchError((onError){
print(onError);
}));
print('end');
}
Future<String> getNetwort(){
return Future((){
sleep(Duration(seconds: 2));
// throw Exception('403');
return "yh";
});
}
//start
//Instance of 'Future<void>'
//end
//yh
//Exception: 403
1.2 async 和 await
版权声明
本文为[weixin_42580612]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_42580612/article/details/124227372
边栏推荐
- Or1k startup file analysis
- How long can we rely on play to earn economic profits?
- Performance test and comparison of oceanbase and MariaDB using dbt-3
- MySQL的深入学习
- Object class
- WSOLA principle and MATLAB simulation
- 二叉排序树基本性质详解
- Inline temporary variables for code refactoring
- How to solve the deadlock problem in MySQL?
- Another perspective on the meta universe: the meta universe culture is quietly changing the world
猜你喜欢

循环链表的创建及可控输出

Creation of circular linked list and controllable output

MySQL execution process

Performance test and comparison of oceanbase and MariaDB using dbt-3

Share price plummeted Robinhood acquired British encryption company for expansion

Development management · Huawei IPD

I'm going to start learning canvas

离散数学(Closure operation)闭包运算全解

The sequence table implements the operation of the stack

金融信息安全实训——22/4/19(上)
随机推荐
循环链表的创建及可控输出
Is it safe to open an account online? How to open an account better?
Dump mangodb data using Navicat
创建双向链表(详解)
Open a new space for development with digital "key"
WSOLA principle and MATLAB simulation
(进阶)C函数调用
Will you "sell" SQL?
【时序】DCRNN:结合扩散卷积和GNN的用于交通流量预测的时空预测网络
【※ LeetCode 劍指 Offer 12. 矩陣中的路徑(簡單)】
Niu Ke's entry record of C language
Leetcode answer notes (I)
MySQL execution process
Nocalhost for dapr remote debugging
How did opensea become the most popular NFT market?
[论文阅读] Active Class Incremental Learning for Imbalanced Datasets
72. 编辑距离
Intel's latest achievement: manufacturing large-scale silicon-based quantum bits
Inductive bias
Binary cross entropy loss function