Hi all, I am new to compose, I would like to have a alert dialog and I need to cancel it on pressing...
n
Hi all, I am new to compose, I would like to have a alert dialog and I need to cancel it on pressing device back button, can any one help me how to implement it in compose.
a
You'll need 3 pieces: 1. A mutable state variable (of Boolean type) to decide whether the alert dialog should be displayed or not. 2. A composable to represent the alert dialog UI. 3. BackHandler to override back button behaviour. Setting step 1's state to false should hide the alert dialog. Typing code on phone is a pain, but I hope you get the gist of it. Feel free to ask if I need to clarify on any point.
n
Thank you @Advitiay Anand, I understood first 2 steps, and I am able to show it on a button click, can you please share the BackHandler code or any link.
👏 1
👍 1