I would like to further express the problem brough...
# compose
f
I would like to further express the problem brought up by @Jacob Applin. Say you have a component that is a text field named
TextField
. And then I want to make a version of that that validates text input named
ValidatedTextField
. I would now need to copy paste the possibly extremely long declaration of
TextField
, as part of the declaration of
ValidatedTextField
, and then feed all of these parameters into
TextField
, and then every time
TextField
adds new arguments I need to add those to
ValidatedTextField
.
l
in case it’s not clear from the discussion below, we are aware of this problem and most of us agree this is a pretty big issue that we want to solve somehow. There are a few proposals we have in mind but it’s something we are still hashing out.
c
I don't get this. Why would this require copy-pasting the content of
TextField
? Why is it not possible to use composition here, i.e., "wrap"
TextField
inside
ValidatedTextField
? As in, why can we not implement
ValidatedTextField
in terms of
TextField
?
f
@curioustechizen The content is not copy-pasted. The definition is. Say this is `TextField`:
Copy code
fun TextField(text : String, decoration: InputDecoration , keyboardType: TextInputType, textCapitalization : TextCapitalization = TextCapitalization.none, style: TextStyle, textAlign: TextAlign = TextAlign.start, textDirection : TextDirection, autoFocus: Boolean = false, obscureText : Boolean = false, autoCorrect : Boolean = false, blah blah blah blah......................){
// Implementation details
}
How would you now define
ValidatedTextField
?
c
Ah I see what you mean now. You're talking about the function signature. (and you say right there in your original message
I would now need to copy paste the possibly extremely long declaration of
TextField
I totally misread that. My bad :)
f
Not only that, but you also need to pump all these fields into the component 'constructor'
c
got it 👍