如果用户开始滚动,我会尝试隐藏容器,以便为 ListView 提供更多空间和可见性。我尝试将 GestureDetector 作为 Listview.builer 的父级并使用其“onVerticalDragStart”,但没有运气。我是 flutter 的初学者,希望您能帮助我。谢谢!
最佳答案
您可以使用 ScrollController
,但是@Sp4Rx提出了更好的解决方案: NotificationListener<ScrollNotification>
您只需包装您的 ListView.builder
在 NotificationListener
具有通用类型 ScrollNotification
处理 ScrollNotification
s通过滚动您的 ListView
发送:
NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) {
if (notification is ScrollStartNotification) {
// Handle your desired action on scroll start here.
}
// Returning null (or false) to
// "allow the notification to continue to be dispatched to further ancestors".
return null;
},
child: ListView.builder(...),
)
您可以查看 ScrollStartNotification
here 的文档.
关于flutter - 如何检测用户是否开始垂直滚动 Listview.builder?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57841166/