小编Ant*_*kin的帖子

未取消 未来

我尝试取消 Future,但仍然在 .then() 中获取执行代码。为什么它不起作用,我做错了什么?

var c = CancelableOperation.fromFuture(
     Future.delayed(new Duration(seconds: 5), () {

     }).then((data){
       print("123"); // This code is always called...
     })

 );
 c.cancel();
Run Code Online (Sandbox Code Playgroud)

asynchronous future dart flutter

5
推荐指数
1
解决办法
1377
查看次数

标签 统计

asynchronous ×1

dart ×1

flutter ×1

future ×1