user6274128
user6274128

Reputation:

Flutter ListView touch listener

How can I find that the user has lifted his finger off the screen after scrolling the ListView. I want to use ScrollController.jumpTo(...) when this event happens. And I couldn't find any callback like this.

PS: I tried using GestureDetector but nothing worked.

Upvotes: 0

Views: 1476

Answers (2)

CopsOnRoad
CopsOnRoad

Reputation: 267404

Wrap your ListView in NotificationListener and listens for UserScrollNotification.

NotificationListener<UserScrollNotification>(
  onNotification: (notification) {
    if (notification.direction == ScrollDirection.idle) {
      print("Scrolling stopped");
    }
  },
  child: ListView.builder(...),
),

Upvotes: 3

user6274128
user6274128

Reputation:

I found that.

ScrollController.position.isScrollingNotifier.addListener(() {// scrolling stopped});

If anyone knows a better solution please write it down. I am more than happy to accept your answer.

Upvotes: 2

Related Questions