Hello, I need to check whether bottom sheet is dismissed or shown and have a code below for two case...
n
Hello, I need to check whether bottom sheet is dismissed or shown and have a code below for two cases. However, dismiss case is also triggered when user selects something and then bottom sheet closes. I don’t want my
onSortingSheetStateChanged(SortSheetState.Dismissed)
to be triggered for that case but only if user presses back button or touches outside. BTW is there any better way to handle these cases?
Copy code
if (sortingBottomSheetState.currentValue != ModalBottomSheetValue.Hidden) {
    DisposableEffect(Unit) {
        onSortingSheetStateChanged(SortSheetState.Shown)
        onDispose {
            onSortingSheetStateChanged(SortSheetState.Dismissed)
        }
    }
}
c
At a minimum to handle the back button, you could use
BackHandler
Overall, using bottom sheet state to trigger behaviour sounds like a bad idea. Can you trigger things another way? Such as “user selects something”, to use your example?