+-

我正在使用ListView小部件将项目显示为列表.在三个窗口中,查看项目必须将中间项目放在中间.
那么当滚动停止时如何检测ListView的位置?
如何检测ListView滚动停止?
最佳答案
我使用了NotificationListener,它是一个小部件,用于侦听冒泡树的通知.然后使用ScrollEndNotification,表示滚动已停止.
对于滚动位置,我使用_scrollController,类型是ScrollController.
new NotificationListener(
child: new ListView(
controller: _scrollController,
children: ...
),
onNotification: (t) {
if (t is ScrollEndNotification) {
print(_scrollController.position.pixels);
}
},
),
点击查看更多相关文章
转载注明原文:android – 如何在Flutter中检测ListView的滚动位置 - 乐贴网