Flutter解决按钮请求防重复提交【转】

onTap: (){
    // 防重复提交
    if(lastPopTime == null || DateTime.now().difference(lastPopTime) > Duration(seconds: 2)){
        lastPopTime = DateTime.now();
        _payOrder(context);
    }else{
        lastPopTime = DateTime.now();
        MyUtils.showMessage("请勿重复点击!");
    }
},

来源:https://blog.csdn.net/codekxx/article/details/102524576

posted @ 2020-09-02 15:49  小猿笔记  阅读(2141)  评论(0编辑  收藏  举报