Complete 状态 ;
二、Future.then 使用
----
调用 then 方法 , 可以在该方法中 , 获取 Future 中的值 , 其类型是 Future 泛型中的类型 ;
调用 testFuture...方法后 , 调用 then 方法 , 可以获取 testFuture 方法返回的 String 字符串 , 就是 s 参数 , 打印该字符串 ;
Future testFuture()..., 在 then 方法后 , 继续调用 Future 的 catchError 方法 ;
Future testFuture() {
return Future.value('success..., 被修饰的方法的 返回值必须是 Future 类型的 ;
方法执行时 , 以 同步的形式 执行到 await 关键字位置 , 然后 挂起 , 等待后续异步方法执行 ;
异步任务执行完毕后 , await...----
有的异步操作可能需要很长时间完成 , 这里为异步操作指定一个超时时间 ;
在 Future 链式调用时 , 调用 timeout 方法 , 设置超时时间 ;
void main() {