Hamba
11/22/2023, 6:10 AMBoxWithConstraints {
println("Box recomposed width: $maxWidth")
Column(
modifier
.pointerInput(Unit) {
detectTapGestures { println("Current box width: $maxWidth") }
}
) { }
}
e.g. if i resize it and then click on the box, it still shows the old width even though it has recomposed.
Box recomposed width: 568.8.dp <- original width
Box recomposed width: 1515.2.dp <- resized width
Current box width: 568.8.dp <- printing width on tap still prints old width even after resizing occurred
I'd have thought the column and its modifier would be recomposed from scratch with the updated maxWidth when the Box is recomposed. how can i make it so the maxWidth printed on tap gesture is updated upon the box being recomposed?Ben Trengrove [G]
11/22/2023, 6:36 AMAlbert Chang
11/22/2023, 6:37 AMModifier.pointerInput
is long-running and won't restart on recomposition automatically, so it only captures the initial value. Read its document for more details.Hamba
11/22/2023, 6:50 AMDivyansh Kushwaha
11/22/2023, 9:57 AM