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.
Asked
Active
Viewed 37 times
2
-
Please add Minimal reproducible code – Rohan Jariwala May 23 '23 at 14:59
-
I used Stack for that, I mean Stack contains 2 children, first the main page code, and second custom loading bar code, and I used GetX to show or hide the loading bar – Aman Programmer May 23 '23 at 15:01
2 Answers
1
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:

Nguyen family
- 749
- 2
- 12