2

I'm trying to display a snackbar in jetpack compose, but it is not displaying the right X close button present on the sample of the documentation. Instead, it's displaying just the message. I can't find how to display that X close button.

here you can see the supposed close button on the right: enter image description here

my code:

val snackbarHostState = remember { SnackbarHostState() } SnackbarHost(hostState = snackbarHostState) uiState.toastMessage?.let { val message = stringResource(it) LaunchedEffect(key1 = message) { snackbarHostState.showSnackbar( message = message, duration = SnackbarDuration.Indefinite ) vm.toastMessage(null) } } 
2

1 Answer 1

3

showSnackbar() takes a withDismissAction parameter. It defaults to false. If you pass true, it apparently adds the close option that you are seeking.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.