mutableStateListOf
Function
Common
@StateFactoryMarker
public fun <T> mutableStateListOf(): SnapshotStateList<T>
Create a instance of MutableList
Common
@StateFactoryMarker
public fun <T> mutableStateListOf(vararg elements: T): SnapshotStateList<T>
Create an instance of MutableList
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)
}
}
}
}
}