mutableStateSetOf

Function

Common
@StateFactoryMarker public fun <T> mutableStateSetOf(): SnapshotStateSet<T>

Create a instance of MutableSet that is observable and can be snapshot.

Common
@StateFactoryMarker
public fun <T> mutableStateSetOf(vararg elements: T): SnapshotStateSet<T>

Create an instance of MutableSet that is observable and can be snapshot.

Code Examples

stateListSample

fun stateListSample() {
    @Composable
    fun Names() {
        var name by remember { mutableStateOf("user") }
        val names = remember { mutableStateListOf<String>() }
        Column {
            Row {
                BasicTextField(value = name, onValueChange = { name = it })
                Button(onClick = { names.add(name) }) { Text("Add") }
            }
            Text("Added names:")
            Column {
                for (addedName in names) {
                    Text(addedName)
                }
            }
        }
    }
}