US Office

1176 Shadeville Rd, Crawfordville Florida 32327, USA

 +1 (850) 780-1313

India Office

Office No 405, Kabir Shilp, Opp. Kansar Hotel, Opp. Landmark, Kudasan, Gandhinagar, Gujarat 382421

[email protected]

How to Disable Swipe to Navigate Back In iOS Flutter?

How to Disable Swipe to Navigate Back In iOS Flutter

How to Disable Swipe to Navigate Back In iOS Flutter?

AppBar Widget or top App Bars is a collection of widgets located at the top of the app, for wrapping our app’s title, icon, and action link.  So in this article How to Disable Swipe to Navigate Back In iOS Flutter.

How to Disable Swipe to Navigate Back In iOS Flutter?

When we needed the user to be able to go back by pressing the “native” back button on the AppBar Widget and I found this niche little flag: userGestureInProgress on the Navigator object.

onWillPop: () async {
    if (Navigator.of(context).userGestureInProgress)
      return false;
      return true;

WillPopScope is the correct way to do this.

It is not complicated. It’s a one-liner :

  onWillPop: () async => false,
  child: <children here>

So a configuration file would make things more complicated as it’s harder to read and maintain.

And remember that in flutter everything is a widget not just half of them. Authentification, configurations, everything.

Open your project in Xcode, find AppDelegate.swift, and add the following:

let controller: FlutterViewController
    = window?.rootViewController as! FlutterViewController;
    .interactivePopGestureRecognizer?.isEnabled = false;

MaterialPageRoute has a parameter called fullscreenDialog which is set to false by default. When true your page animates a bit differently and swipe to go back on iOS will be disabled.

So here’s an example usage:

        MaterialPageRoute(builder: (_) => HomePage(), fullscreenDialog: true));


Thanks for Reading !!! Keep Learning!!! Keep Fluttering!!!

So in this article, we have been through how to disable swipe to navigate back in iOS flutter.

Let us know in the comments, how much did you learn from the article 🙂

Do let us know if you need any assistance with flutter development. We would love to assist you. is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc. is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

Post a Comment