Rearrange the following code lines to create a Switch and a Text composable below it. The Text should dynamically display "On" when the Switch is checked, and "Off" when it's unchecked.
Checkbox, Radio Button, and Switch
Switch it off
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
Column {
)
@Composable
var switchState by remember { mutableStateOf(false) }
onCheckedChange = { switchState = it }
}
}
checked = switchState,
fun SwitchExample() {
Text("State: ${if (switchState) "On" else "Off"}")
Switch(
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.