I started to learn Jetpack Compose and it looks confusing how to implement a simple snackbar, using material3 dependencies.
Documentation shows I need a scaffold and it needs a content with padding (?). Do I need put my screen composable inside scaffolds lambda? How do I pass my message text to Snackbar? I have a simple flow collector for event from viewmodel where I want to pass the error text to snackbar.
Test()
LaunchedEffect(Unit) {
viewModel.loginEvent.collect {
when (it) {
is LoginViewModel.LoginEvent.Error -> {
// show snackbar with it.error
}
is LoginViewModel.LoginEvent.Success -> {
//
}
}
}
}
@Composable
fun Test() {
Box(modifier = Modifier.fillMaxSize()) {
//my composable screen
}