Daniele Segato
07/08/2021, 9:37 AMModifier.onSizeChange()
doesn't work in Preview?
var cardSize by remember { mutableStateOf<IntSize?>(null) }
Box(
modifier = Modifier
.background(Color.White)
.aspectRatio(1f)
.fillMaxSize()
.onSizeChanged { cardSize = it }
) {
Text(text = "Size is = $cardSize")
}
the preview always show "Size is null" while if I run it I get the size as I expect?
Is there a way to fix the preview?maxWidth
but this is kind of weirdms
07/08/2021, 9:43 AMAlbert Chang
07/08/2021, 9:48 AMDaniele Segato
07/08/2021, 10:25 AMI guess you need the interactive mode for the text to get updated.I think it's disabled in AS Beta
Albert Chang
07/08/2021, 10:35 AMDaniele Segato
07/08/2021, 1:06 PMZach Klippenstein (he/him) [MOD]
07/08/2021, 2:35 PMBoxWithConstraints
might be a better approach if it works for your use case since it gives you the constraints immediately, on the first composition. No missed frame, no flickerDaniele Segato
07/08/2021, 6:30 PMZach Klippenstein (he/him) [MOD]
07/08/2021, 6:34 PM