mutableStateSetOf
Function
Common
@StateFactoryMarker public fun <T> mutableStateSetOf(): SnapshotStateSet<T>
Create a instance of MutableSet
The returned set iteration order is in the order the items were inserted into the set.
Common
@StateFactoryMarker
public fun <T> mutableStateSetOf(vararg elements: T): SnapshotStateSet<T>
Create an instance of MutableSet
The returned set iteration order is in the order the items were inserted into the set.
Code Examples
stateSetSample
fun stateSetSample() {
    @Composable
    fun DaysForAlarm() {
        val days = remember { mutableStateSetOf<DayOfWeek>() }
        Column(Modifier.selectableGroup()) {
            DayOfWeek.entries.forEach { dayOfWeek ->
                Row(
                    modifier =
                        Modifier.toggleable(
                            value = dayOfWeek in days,
                            role = Role.Checkbox,
                            onValueChange = {
                                if (it) {
                                    days.add(dayOfWeek)
                                } else {
                                    days.remove(dayOfWeek)
                                }
                            },
                        )
                ) {
                    Checkbox(checked = dayOfWeek in days, onCheckedChange = null)
                    Text(text = dayOfWeek.name)
                }
            }
        }
    }
}
