Flutter: Disable Swipe to Navigate Back in iOS and Android

WillPopScope is the correct way to do this.

(it seems too complicated… it should be easier… like a setting on the root app).

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

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

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.

Leave a Comment