https://kotlinlang.org logo
#compose
Title
# compose
l

loloof64

12/31/2021, 9:20 AM
Hi ! I know that there's something wrong in my
@Composable
code, but don't know what. Because when I rotate the device, the value of
pageIndex
switches between two values instead of keeping the same value. More in 🧵
This is my
@Composable
.
pageIndex
is saved with
rememberSaveable
, and I have to use some logic inside
SideEffect
.
I think it is because of the
if
clause : if in portrait, will only update
MyPortraitComposable
otherwise will only update
MyLandscapeComposable
. But I don't know how to overcome the issue.
This time I am using a custom layout and removed SideEffect block, but no improvement in the behaviour. Even worse, on each rotation, the value of pageIndex is reset to 0.
Oups sorry for this dumb question : in fact it was because I had set a listener to the text input focus changed, which reset the pageIndex on loading.