flutter - 使用 onscroll 扑动 ontap
问题描述
我正在垂直进行自动滚动,并且在滚动期间我想要应用 Ontap 操作,正如您在示例中看到的那样,我无法记录打印操作:
ps:我已经尝试过该解决方案,但这不是我要在这里寻找的
@override
void initState() {
super.initState();
Future.delayed(Duration(milliseconds: 100)).then((value) {
if (_scrollController.hasClients)
_scrollController.animateTo(100,
duration: Duration(seconds: 5), curve: Curves.ease);
});
}
SingleChildScrollView(
controller: _scrollController,
scrollDirection: Axis.vertical,
physics: NeverScrollableScrollPhysics(),
child: GestureDetector(
onTap: () {
print('clicked');
},
child: Container()
}
)
)
谢谢,
解决方案
你会尝试这样做吗
SingleChildScrollView(
controller: _scrollController,
scrollDirection: Axis.vertical,
physics: NeverScrollableScrollPhysics(),
child: GestureDetector(
onTap: () {
print('clicked');
},
child: Container()
}
),
)
至
GestureDetector gestureDetector = GestureDetector(
child: Container(),
onTap: () => print('clicked'),);
SingleChildScrollView(
controller: _scrollController,
scrollDirection: Axis.vertical,
physics: NeverScrollableScrollPhysics(),
child: gestureDetector,)
和
Future.delayed(Duration(milliseconds: 100)).then((value) {
if (_scrollController.hasClients){
_scrollController.animateTo(100,
duration: Duration(seconds: 5), curve: Curves.ease);
gestureDetector.onTap();
});
推荐阅读
- powerbi - 如何在 Powerbi 中实现列级安全性?
- html - 我想使用 CSS 更改容器颜色的颜色。我在下面尝试过的代码似乎不起作用:
- javascript - 提供者无法在 react-redux 中将状态作为道具传递
- tensorflow - 关于 tf.gfile.FastGFile 和 cv2 mat
- javascript - 打开一个新窗口检查属性是否在页面的新窗口中
- c++ - 构建多线程 C++ 服务器的问题
- python - 通过使用 python 解析文件来创建一组框及其连接
- python-3.x - 如何用 python,Tkinter 制作图形,不在矩形窗口内?
- python - 连接多个数据帧。数据路径问题
- django - django 图像看不到