Hi, I had a question regarding default value for `...
# compose
w
Hi, I had a question regarding default value for
Modifier
as a parameter, apparently
fillMaxWidth
is ignored if passed like this.
Copy code
@Composable
fun TextButton(
    modifier: Modifier = Modifier.fillMaxWidth(),
yeah, that’s the way to go, thanks.
t
Or just
modifier.fillMaxWidth()
This is perfectly idiomatic and is used throughout the Compose codebase.
l
yep. convention is to have the default expression just be
modifier: Modifier = Modifier
and then just start your modifier chain with that:
Copy code
InternalTextButton(modifier = modifier.fillMaxWidth().etc(...)
note that the documents saying
the first modifier parameter must: …
are indicating what the convention is, not what is technically allowed/not allowed. what you wrote initially was perfectly valid kotlin, just not what you wanted 🙂
google 1
👍 1
d
convention is to have the default expression just be
modifier: Modifier = Modifier
Oh, I guess I'll add it to the detekt-rules-compose as a new (togglable) rule. UPD: turns out there was already an issue-request for such a rule