I need to provide in-app dark and light theme feat...
# compose
a
I need to provide in-app dark and light theme feature. Currently, I am changing theme using
isSystemInDarkTheme
but how to change theme using user input ?
f
Just have a separate value stored somewhere that switches the colors of your theme (e.g.
MaterialTheme
). e.g.
Copy code
var userWantsDarkTheme by remember { mutableStateOf(false) }
val colors = when {
    isSystemInDarkTheme() && userWantsDarkTheme -> darkColors()
    else -> lightColors()
}
MaterialTheme(colors = colors) { Content() }
a
Thanks
I tried the above approach but when theme state changes app get refreshed
Is there any way to resolve above