例如,我有 SingleChildScrollView
和 BouncingScrollPhysics
。
当内容从边缘跳转时,我想要类似 print(_overscrollOffsetValue)
的东西,例如overscroll 的偏移值越大,_overscrollOffsetValue
就越大。
最佳答案
您可以监听 ScrollUpdateNotification:
NotificationListener<ScrollNotification>(
onNotification: (notification) {
if (notification is ScrollUpdateNotification) {
final offset = notification.metrics.pixels;
if (offset < 0) {
print(offset.abs());
}
}
return false;
},
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Text('A' * 10000),
),
)
关于flutter - 如何获取 BouncingScrollPhysics overscroll 值偏移量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61643224/