I want to intercept the back gesture or tap (e.g., swiping back on iOS or pressing the back button or gesture on Android) to show a dialog before exiting a screen.
I understand that in Jetpack Compose, I could use BackHandler, but since I am working with Compose Multiplatform, that is not an option. It seems I might need to implement platform-specific logic to achieve this.
I’ve searched for solutions or examples related to this issue but haven’t found any information specifically for Compose Multiplatform. How can I handle this behavior for both Android and iOS? Thanks
Since 1.8.0-alpha03, there is a solution on Compose Multiplatform itself! https://github.com/JetBrains/compose-multiplatform/releases/tag/v1.8.0-alpha03
There is a small weird thing: You can't access BackHandler and PredictiveBackHandler on your code unless you manually implement the following library: org.jetbrains.compose.ui:ui-backhandler
After that it should work, at least for this alpha version it is the only solution