If I am using WillPopScope to overwrite the BackButton behavior with a new route, it works fine. But on iOS, the automatic 'SwipeBack' gesture is not working any more. How can I set the SwipeBack gesture on iOS to push the current screen to the page with the class 'StartScreen'?
WillPopScope(onWillPop: (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => StartScreen(),
),
);
}
Answer: A: As stated in this article, Switch between apps on iPad - Apple Support. To turn off the multifinger swipe gesture, go to Settings > Home Screen & Dock > Multitasking.
This may be a very late answer, but at the moment there is no clear opportunity to listen to this gesture
You can achieve the call to onWillPop when you press the back button, and at the same time do not block the gesture if you make a descendant class of the ModalRoute class (or its descendants, such as MaterialPageRoute) and override the hasScopedWillPopCallback method (however, the gesture will not call onWillPop)
WillPopScope
is not meant to affect navigation (I.e.: push a route on the navigator). It is meant for vetoing (preventing) navigation away from the current route when you don't want the user to navigate away. (For example, when it might result in data loss.)
Try CupertinoWillPopScope, as it allows you to conditionally veto the back navigation. So you can only block it when there's an actual need.
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