How to deactivate back button in flutter?

In some sceanarios we want to behaviour of the android back button press event of the current screen. To disable back button event in the flutter there is a widget called WillPopScope widget which can handle the back button event in the android devices.

Example to handle the back button event in flutter

Widget build(BuildContext context) {
  return new WillPopScope(
    onWillPop: () async => false,
    child: new Scaffold(
      appBar: new AppBar(
        title: new Text("data"),
        leading: new IconButton(
          icon: new Icon(Icons.ac_unit),
          onPressed: () => Navigator.of(context).pop(),



This will disable the android back button event, if we want to go abck to previous screen we can use Navigatior.pop() method


Subscribe For Daily Updates

Flutter Questions
Android Questions