rememberScaffoldState
was removed in material 3, the migration docs reads
The M2 ScaffoldState class no longer exists in M3 as it contains a drawerState parameter which is no longer needed. To show snackbars with the M3 Scaffold, use SnackbarHostState instead:
So this is how you would show a snackbar in material 3.
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
val snackbarHostState = remember { SnackbarHostState() }
val scope = rememberCoroutineScope()
Scaffold(
snackbarHost = { SnackbarHost(snackbarHostState) },
content = {
…
Button(
onClick = {
scope.launch {
snackbarHostState.showSnackbar(
message = "Hey this is a snackbar",
actionLabel = "Click me",
duration = SnackbarDuration.Short
)
}
})
{
Text(text = "Click me")
}
}
)