Replace the current initialization of val snackbarHostState = SnackbarHostState() with val snackbarHostState = remember { SnackbarHostState() }. This change is aimed at following proper state management within the component.
val snackbarHostState = SnackbarHostState()
↓
val snackbarHostState = remember { SnackbarHostState() }
Idea Description
Replace the current initialization of val snackbarHostState = SnackbarHostState() with val snackbarHostState = remember { SnackbarHostState() }. This change is aimed at following proper state management within the component.
Reference images and links https://developer.android.com/reference/kotlin/androidx/compose/material3/SnackbarHostState#showSnackbar(androidx.compose.material3.SnackbarVisuals)