@Composable
fun SnackbarScreen() {
val scope = rememberCoroutineScope()
val snackbarHostState = remember { SnackbarHostState() }
.
.
.
FloatingActionButton(
onClick = {
//Important part here
scope.launch {
snackbarHostState.showSnackbar("Hello there")
}
//
},
content = { Icon(imageVector = Icons.Default.Add, contentDescription = "") }
)
SnackbarHost(hostState = snackbarHostState)
}