Is this the correct way to use movableContentOf? I...
# compose
z
Is this the correct way to use movableContentOf? If i start the app in portrait then rotate to landscape and rotate back it crashes.
Copy code
FATAL EXCEPTION: main
Process: com.hyperion, PID: 13405
java.lang.ArrayIndexOutOfBoundsException: length=7430; index=7431
	at androidx.compose.runtime.SlotTableKt.hasMark(SlotTable.kt:3169)
	at androidx.compose.runtime.SlotTableKt.access$hasMark(SlotTable.kt:1)
	at androidx.compose.runtime.SlotReader.hasMark(SlotTable.kt:827)
	at androidx.compose.runtime.ComposerImpl.reportFreeMovableContent$reportGroup(Composer.kt:3500)
	at androidx.compose.runtime.ComposerImpl.reportFreeMovableContent(Composer.kt:3593)
+ 300 more lines
a
Yeah that looks correct, this seems like a bug in Compose. Could you report it with a repro? As a workaround you might be able to get away with just:
Copy code
Row(
        modifier = Modifier.padding(paddingValues)
    ) {
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            NavRail(
                currentDestination = currentDestination,
                onClickDestination = mainRootNavigator::replace
            )
        }
        taxi(Modifier.weight(1f))
    }
and not need
movableContentOf
z
I was doing something like that before which did work. I felt that it wasn't optimized with the unnecessary Row when in portrait mode
a
I wouldn’t be worried about an extra
Row
at all, Compose is really good about nesting layouts for cases like this. Your use of
movableContentOf
should work though, just wanted to make sure you weren’t blocked on figuring that out 😄