Search code examples
androidflutterflutter-getx

How to make flutter screen unclosable?


I am working on a flutter application, where I made my custom loading bar, so whenever I set the value of loading bar *true, it shown up. But the main problem is, when I hit the back button, It goes back and loading bar get closed. I want it to never close. And again, I am not talking about showDialog function. Please help me flutter developers. Thank you.


Solution

  • Yes, we're talking about WillPopScope. This will catch event your press back button in Android or swipe back in iOS. All you need is just wrap your Scaffold inside WillPopScope:

    WillPopScope(
          onWillPop: () async {
            // do something...
          },
          child: Scaffold()
    )
    

    References: