flutter中InkWell 和 GestureDetector快速、频繁点击时表现出不响应或“点不到”的情况分析

背景:
之前没有详细的用到这一块,最近自己做了一个竞速类的工具,主打一个快速输入之后快速提交。

结果,老是提交之后,不能快速的拿到输入栏的结果,明明已经输入了,却显示null。
一开始以为是放在setState方法中,有延迟,于是拿了出来,不在setState方法中改变初始值。

后面发现还是不行,输入快,点击快的情况下,还是会把输入的内容漏掉。

这时的我不得不分析我是否用错了控件。

原来代码如下:

class CustomButton extends StatelessWidget {
  final String label;
  final VoidCallback onTap;
  final VoidCallback? onLongPress; // 添加这个字段
  static const TextStyle top_two_style = TextStyle(
      fontSize: 18, color: Color(0xff353e4d), fontWeight: FontWeight.w500);
  const CustomButton({Key? key, required this.label, required this.onTap,this.onLongPress}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(1),
      child: Material(
        color: AppColors.APPKeyLightColor,
        shape: const RoundedRectangleBo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值