Last active
March 29, 2021 17:14
-
-
Save igorescodro/024cf8a6f69bc622a8b32fdfcf6f5c31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun SnackbarSample() { | |
val snackbarHostState = remember { SnackbarHostState() } | |
val coroutineScope = rememberCoroutineScope() | |
val modifier = Modifier | |
Box(modifier.fillMaxSize()) { | |
Button(onClick = { | |
coroutineScope.launch { | |
snackbarHostState.showSnackbar(message = "This is a Snackbar") | |
} | |
}) { | |
Text(text = "Click me!") | |
} | |
SnackbarHost( | |
hostState = snackbarHostState, | |
modifier = Modifier.align(Alignment.BottomCenter) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment