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

Colton Idle

09/15/2020, 2:41 AM
Okay, I feel really dumb. I have a new project and I'm just trying to add a simple material TextField to the screen. Why is this not working? TextField seems to accept a string value, and a onValueChange of a string as well.
Copy code
TextField(value = "first", onValueChange = { s: String -> })
z

Zach Klippenstein (he/him) [MOD]

09/15/2020, 4:49 AM
How is it not working?
c

Colton Idle

09/15/2020, 5:22 AM
v

Vinay Gaba

09/15/2020, 5:28 AM
it requires another parameter to be passed -
label
. Just add this
Copy code
label = {
  Text("Some label")
}
z

Zach Klippenstein (he/him) [MOD]

09/15/2020, 5:29 AM
or
label = {}
p

Philip Blandford

09/15/2020, 5:47 AM
I'm always tripping up over this - maybe label should have a default value of an empty block?
👍 3
o

outadoc

09/15/2020, 8:18 AM
That error is not very helpful 😓
☝️ 1
a

Anastasia [G]

09/15/2020, 12:52 PM
FIY label parameter became optional (alpha03)
c

Colton Idle

09/15/2020, 1:19 PM
Omg. Thank you all. Will try this later today. Glad I wasn't the only one that was tripped up by something so small. That error message did not help.
a

Anastasia [G]

09/15/2020, 1:26 PM
Well, it seems to me that the error message kinda have all we need to understand the issue (if we look at message and bold red). Though I agree that it might not be very obvious, especially if you hit this issue for the first time. If someone has an idea how this could be improved, please feel free to file a bug
h

Halil Ozercan

09/15/2020, 3:09 PM
The reason why error message doesn't help is that for some reason optional argument names are written in the error but must arguments have only type signature, no name at all. If it were to write
label: () -> Unit
in red, then it could be way easier to spot the error.
1
c

Colton Idle

09/15/2020, 7:30 PM
@Anastasia [G] hm. I see the error message has something in bold red, but it doesn't tell me what it is. It just says
() -> Unit
a

Anastasia [G]

09/15/2020, 9:23 PM
Fair enough!