Mark
11/15/2023, 5:24 AMText
showing the updated text, but not the second Text
?
@Preview(showBackground = true)
@Composable
fun WithConstraintsComposable() {
var text: String by remember {
mutableStateOf("not set")
}
Column {
BoxWithConstraints {
text = "My minHeight is $minHeight while my maxWidth is $maxWidth"
Text(text, modifier = Modifier.background(Color.Green))
}
Text(text, modifier = Modifier.background(Color.Red))
}
}
Ben Trengrove [G]
11/15/2023, 5:29 AMtext =
, this is actually probably a backwards write because BoxWithConstraints is a subcompose layout and so runs after the bottom text.
https://developer.android.com/jetpack/compose/performance/bestpractices#avoid-backwardsBen Trengrove [G]
11/15/2023, 5:29 AMMark
11/15/2023, 5:33 AMshikasd
11/15/2023, 11:32 AM