Skip to content

Instantly share code, notes, and snippets.

@mohanmanu484
Last active December 7, 2023 07:36
Show Gist options
  • Select an option

  • Save mohanmanu484/2b4e3a55b53eb83ea42c30f97061e29b to your computer and use it in GitHub Desktop.

Select an option

Save mohanmanu484/2b4e3a55b53eb83ea42c30f97061e29b to your computer and use it in GitHub Desktop.
UserItem
@Parcelize
data class CheckBoxState constructor(
val isSelected: Boolean = false,
val name: String = "Checkbox State"
) : Parcelable
@Composable
fun UserItem() {
var checkBoxState by rememberSaveable {
mutableStateOf(CheckBoxState())
}
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(checked =checkBoxState.isSelected , onCheckedChange = {
checkBoxState =checkBoxState.copy(isSelected = it)
})
Text(text = checkBoxState.name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment