I encountered an issue when using the ModalBottomSheetLayout component in Jetpack Compose. Here is my code:
ModalBottomSheetLayout(
modifier = Modifier.fillMaxSize(),
sheetState = bottomSheetState,
sheetContent = {
...
})
When I call bottomSheetState.show()
and immediately press the physical back button, it navigates back to the previous screen, but the ModalBottomSheetLayout does not close. At that moment, checking bottomSheetState.isVisible
returns false. From my understanding, when calling bottomSheetState.show()
, the ModalBottomSheetLayout slides up from the bottom, but bottomSheetState.isVisible does not change until the animation completes. How should I handle the back event in this situation?