Jetpack Compose 1.7 Essentials was published on October 28, 2024.
The current revision is 1.0. The revision of your book can be found on the copyright page at the start of the book.
The code example in this section omits the call to FunctionB. It should read as follows:
@Composablefun DemoScreen(modifier: Modifier = Modifier) {
var textState by remember { mutableStateOf("") }
val onTextChange = { text : String ->
textState = text
}
Column {
MyTextField(text = textState, onTextChange = onTextChange)
FunctionA()
}
}
.
.
@Composablefun FunctionA() {
var switchState by remember { mutableStateOf(true) }
val onSwitchChange = { value : Boolean ->
switchState = value
}
FunctionB(
switchState = switchState,
onSwitchChange = onSwitchChange
)
}
@Composablefun FunctionB(switchState: Boolean, onSwitchChange : (Boolean) -> Unit ) {
Switch(
checked = switchState,
onCheckedChange = onSwitchChange
)
}
Code language: Kotlin (kotlin)
If you have encountered an issue with the book not listed above, please contact us, and we will work to resolve the issue for you as quickly as possible.