Код: Выделить всё
@Composable
fun Func() {
val myMutableState = remember { mutableStateOf(true) }
Column {
AnotherFunc(mutableValue = myMutableState)
Text(if (myMutableState.value) "Stop" else "Start")
}
}
@Composable
fun AnotherFunc(mutableValue: MutableState) {
}
К сожалению, приведенный ниже код не скомпилируется. Это потому, что я не могу передать его через функцию AnotherFunc(mutableValue = myMutableState)
Код: Выделить всё
@Composable
fun Func() {
val myMutableState by remember { mutableStateOf(true) }
Column {
AnotherFunc(mutableValue = myMutableState) // Error here
Text(if (myMutableState) "Stop" else "Start")
}
}
@Composable
fun AnotherFunc(mutableValue: MutableState) {
}
Подробнее здесь: https://stackoverflow.com/questions/706 ... e-function
Мобильная версия