I'm using ListView
widget to show items as a list. In a window three, items viewing must the middle item place in the middle.
So how can I detect position of ListView
when scrolling stop?
How to detect ListView Scrolling stopped?
A scroll controller creates a [ScrollPosition] to manage the state-specific to an individual [Scrollable] widget. To use a custom [ScrollPosition], subclass [ScrollController] and override [createScrollPosition]. A [ScrollController] is a [Listenable].
forward, then scroll offset is the amount the top of the sliver has been scrolled past the top of the viewport. This value is typically used to compute whether this sliver should still protrude into the viewport via SliverGeometry. paintExtent and SliverGeometry.
I used NotificationListener
that is a widget that listens for notifications bubbling up the tree. Then use ScrollEndNotification
, which indicates that scrolling has stopped.
For scroll position I used _scrollController
that type is ScrollController
.
NotificationListener( child: ListView( controller: _scrollController, children: ... ), onNotification: (t) { if (t is ScrollEndNotification) { print(_scrollController.position.pixels); } }, ),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With