Skip to content

Instantly share code, notes, and snippets.

@takahirom
Created December 4, 2021 08:43
Show Gist options
  • Save takahirom/5bea30b0fd0818c1fa088d853414e94e to your computer and use it in GitHub Desktop.
Save takahirom/5bea30b0fd0818c1fa088d853414e94e to your computer and use it in GitHub Desktop.
@Composable
fun MySwitch() {
​// I have a State in Compose's MutableState
​val checked = remember { mutableStateOf(false) }
​Switch(
​// Observe the State by accessing the value property
​checked = checked.value,
​onCheckedChange = {
checked.value = it
​}
​)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment