I used onKeyDown function in the activity.....but when back button button is clicked it first cancels the dialog box and goes to our activity...I want both either both activity and dialog box closed when clicking the back button or disable the back button when the dialog box is shown...
can any one suggest any solutions for this....
Thanks in advance,
Update
Hello Thanks for your answer.
The progressDialog
with .setCancelable(false);
is working fine.
But here I want different thing. When the progress dialog is running then i will press the BACK key and i want to show an alert dialog so that the user can notify that the progress is running.
Is there any solution about it?
Please help me.
Thanks in advance.
To disable back button in Flutter, you can use the WillPopScope widget. The WillPopScope widget helps you get a callback whenever the back button is pressed. Inside the callback, if you return true the screen will be popped and if you return false, you have simply disabled the back button.
The below code will close AlertBox/DialogBox in Flutter. Navigator. of(context). pop();
showDialog<T> function Null safety. Displays a Material dialog above the current contents of the app, with Material entrance and exit animations, modal barrier color, and modal barrier behavior (dialog is dismissible with a tap on the barrier). This function takes a builder which typically builds a Dialog widget.
Did you try setting its setCancelable()
property to false
Something like this
progressDialog.setCancelable(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With