Hi, how could I have multiple text fields that can...
# compose
a
Hi, how could I have multiple text fields that can be errored affect if a button is enabled or not, if one of the text field is errored, the button is disabled, and if possible I want to show why it is disabled when hovering the button. So I created a class for my custom errors
Copy code
data class ErrorCreate<T>(val error: String, val name: String, val value: T)
(I need to store the bad value and it can be a string/int/float/boolean) Then I created this top-first variable
Copy code
val canCreate = mutableStateListOf<ErrorCreate<*>>()
And for now I just have
Copy code
Button(
    enabled = canCreate.isEmpty(),
    modifier = ...
) { Text("Create") }
And in my textfields
onValueChange
function, I add an error to the
canCreate
array if it is errored, otherwise I remove it filtered by name. But, the problem is that when I add something to the list, my button is not directly updated but is next time the list changes, so it doesn't really work, is there any workaround or other solution to make this possible ?
👍 1