我想传递状态,但它抛出错误"val不可重新分配".
@Composable
fun MyUi() {
var showContent by remember { mutableStateOf(false) }
if (showContent) {
MyButton(showContent)
}
}
@Composable
fun MyButton(showContent: Boolean) {
// very long content
Button(onClick = {
showContent = true
}) {
Text(text = "Very long content")
}
}