Hi! Anyone has an example on how to show a Modal b...
# compose
a
Hi! Anyone has an example on how to show a Modal bottom sheet ? I think i'm doing something wrong.. .but cannot find what is, code in thread
Copy code
val coroutineScope = rememberCoroutineScope()
val bottomSheetState = rememberModalBottomSheetState(
    initialValue = ModalBottomSheetValue.Hidden,
)
ModalBottomSheetLayout(sheetContent = { Text("Hello!") }) {
    Button(onClick = {
        coroutineScope.launch {
            if (bottomSheetState.isVisible) {
                bottomSheetState.hide()
            } else {
                bottomSheetState.show()
            }
        }
    }) {
        if (bottomSheetState.isVisible) {
            Text(text = "Hide")
        } else {
            Text(text = "Show")
        }
    }
}
m
You need to pass the
bottomSheetState
as parameter to
ModalBottomSheetLayout
a
oooooh
that makes sense ¬¬
of course
thanks @ms