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

Sean Proctor

03/12/2024, 10:17 PM
Is there a problem with nesting movable content? I'm getting a crash when the outer content is moved when it contains another movable content.
No, I think it's fine. I had a different bug that I don't quite understand.
Copy code
@Composable
fun ConditionalContainer(
    condition: Boolean,
    trueContainer: @Composable (content: @Composable (Modifier) -> Unit) -> Unit,
    falseContainer: @Composable (content: @Composable (Modifier) -> Unit) -> Unit,
    content: @Composable (Modifier) -> Unit
) {
    val movableContent = remember(content) { movableContentOf(content) }
    if (condition) {
        trueContainer(movableContent)
    } else {
        falseContainer(movableContent)
    }
}
the keys to the remember should also include
condition
because the passed in modifier changes. For some reason this bug only shows up when it's inside another container.