Flutter Cookbook #1: Swipe past last widget in the PageView and load the next screen :)

Scroll this


  • User is swiping through the PageView widgets
  • User arrives to the last widget
  • Instead of forcing the user to tap on button, we want user to continue swiping in order to swipe from last widget and load the next screen

Initial setup:

For full example checkout: github.com/dribtech/flutter_swipe_past_last_page/blob/eaba683bd337aca9211eb3c172d1cd831605d2ff/lib/main.dart


Wrap PageView with NotificationListener<OverscrollNotification> in order to catch the over-scroll event and load the next screen:

The 10 in the if(overscrollNotification.overscroll < 10) { is the “amount” of over-scroll that must be reached before we load the next screen. Without it accidental taps would
trigger loading of the next screen. Experiment which number works best for you.

For full example checkout github.com/dribtech/flutter_swipe_past_last_page/blob/master/lib/main.dart

Or visit: github.com/dribtech/flutter_swipe_past_last_page

Other popular solutions

GestureDetector & NeverScrollableScrollPhysics

Wrap the PageView with GestureDetector and add physics: NeverScrollableScrollPhysics() in PageView .

Pros: reacts on “drag” no need to guess amount of over-scroll. We must implement scrolling between PageView widgets.

Cons: also overrides default look and feel when swiping between PageView widgets. And this was a deal breaker for me.


Wrap PageView with  NotificationListener<OverscrollIndicatorNotification>and implement onNotification

Cons: reacts on the slightest tap instead of clear drag

Submit a comment