https://kotlinlang.org logo
#compose
Title
# compose
d

Daniele B

03/14/2024, 8:40 AM
I would like to remember a list of TextField values. In the BasicTextField I am using
remember { filters.toMutableStateList() }
Copy code
fun Filter(filters: List<String>) {
    val filterValues = remember { filters.toMutableStateList() }
    ...BEGIN for loop....
       BasicTextField(
          value = filterValues[index],
          onValueChange = {
             filterValues[index] = it
             filterListFunction(filterValues)
          })
    ...END for loop....
}
What is the idiomatic way in BasicTextField2?
h

Halil Ozercan

03/20/2024, 9:28 PM
You can do something like
Copy code
val state = rememberTextFieldState()
LaunchedEffect(state) {
  snapshotFlow { state.text }
    .collectLatest {
      previousValues += it
    }
}
d

Daniele B

03/21/2024, 2:42 PM
They are actually values for multiple textboxes (identified by an index), which I am currently remembering as a statelist
2 Views