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

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

        },
)

你可能感兴趣的:(Flutter)