flutter - 检测 IgnorePointer 或 AbsorbPointer 内的某些小部件上的指针事件
问题描述
IgnorePointer
例如,是否可以检测到 Flutter 内部或Flutter中某个 Widget 上的点击事件AbsorbPointer
?
代码示例:
AbsorbPointer(
absorbing: *some condition to make it true or false*,
child: ListView(
children: [
SomeButton(
onTap: () => print("i want this method to run when this button is tapped even if absorbing is true"),
),
...
],
),
),
解决方案
只是出于好奇,您为什么使用小部件只是为了拿走该小部件的主要功能我只是好奇?所以答案AbsorbPointer
是肯定的,你可以包装一个小部件AbsorbPointer
,RawGestureDetector
然后定义你自己的手势工厂来覆盖rejectGestures
,这样它就可以接受所有手势,然后GestureArena
仍然会注册点击。对于IgnorePointer
此设置将不起作用。我想不出任何覆盖IgnorePointer
.
SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
//Column Content
],
),
),
你也可以换行AbsorbPointer
,Listener
因为这不使用GestureArena
如果你想了解更多关于这个 Nash 写了一篇很棒的文章Flutter Deep Dive: Gestures
推荐阅读
- scala - 给定一个字符串列表,我如何检查这些字符串是否在 Scala 的列表中?
- microservices - servicefabric steteless 服务实例计数 6 当节点计数 5 出错时
- php - 插入数据后是否可以在不插入codeigniter的情况下立即显示表格行?
- java - 如何使用apache poi在excel表格中为特定行或标题添加背景颜色
- bootstrap-4 - 如何配置 URL 段 (typo3 10.2.0)
- python - 加速蛮力“统计”算法的任何替代方法?
- python - Tensorflow 的 Python 多处理工作队列
- html - 使动画等到到达部分页面
- python-3.x - 如何在python中读取文件
- algorithm - 创建一个算法来确定上下文无关语法是否可以生成空词(ε)