Sebastian Schuberth
06/02/2024, 12:29 PMrememberWindowState
in rememberSaveable
but keep getting "@Composable invocations can only happen from the context of a @Composable function" although I've moved the code already to a `@Composable`function:
fun main() = application {
createMainWindow { ::exitApplication }
}
@Composable
fun createMainWindow(onCloseRequest: () -> Unit) {
val rememberedState = rememberSaveable { rememberWindowState(width = Dp.Unspecified, height = Dp.Unspecified) }
Window(
onCloseRequest = onCloseRequest,
state = rememberedState,
title = "Stan"
) {
var text by remember { mutableStateOf("Hello, World!") }
Button(onClick = { text = "Hello, Desktop!" }) {
Text(text)
}
}
}
zt
06/02/2024, 3:46 PMSebastian Schuberth
06/02/2024, 3:50 PMrememberSaveable
saves be to do manually.zt
06/02/2024, 3:51 PMIvan Matkov
06/03/2024, 7:56 AMrememberSaveable
wipes the data when user explicitly closes the app on android. It's for things like restart due to config changes or memory optimizations.
If you need a custom behaviour - it can be provided via LocalSaveableStateRegistry
Ivan Matkov
06/03/2024, 8:06 AMrememberSaveable is really only useful on AndroidNope - it's used for saving things like scroll position during navigation back
zt
06/04/2024, 1:14 AMmikehearn
06/05/2024, 9:21 AMmikehearn
06/05/2024, 9:21 AM