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.
2
Answers
You probably need to use the widget
WillPopScope
: it prevents the user from closing/going back unless the condition specified in theonWillPop
argument istrue
. Just setonWillPop
to always returnfalse
, and you should be good to go.See here.
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 yourScaffold
insideWillPopScope
:References: