- I have displayed a snackbar with
Floating Action Button
butSnackbar
shows up above theFAB
and it want it show it below theFAB
. - As per the guidelines snackbar must be above FAB but in the app as per the funtionality I have to display it below.
- I also tried with
Modifier.offset()
but Snackbar is sticked with FAB offset. - There is a simliar question here here but that doesn't answer the question.
Here is some snippet of my code:
@Composable
fun snackBarDemo() {
val coroutineScope = rememberCoroutineScope()
val snackBarHostState = remember { SnackbarHostState() }
val drawerState = rememberDrawerState(DrawerValue.Closed)
val scaffoldState = rememberScaffoldState(drawerState, snackbarHostState)
Scaffold(
scaffoldState = scaffoldState,
drawerContent = {},
floatingActionButton = {
FloatingActionButton(
onClick = {
coroutineScope.launch {
scaffoldState.snackbarHostState.showSnackbar("Hello this is my snackbar")
}
}) {
Icon(
painter = painterResource(id = R.drawable.icon),
contentDescription = null,
modifier = Modifier.padding(start = 5.dp, top = 2.dp)
)
}
}
) {}
}