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

Kshitij Patil

12/24/2020, 5:08 PM
I sometimes get warning of putting
modifier
as first optional argument. May I know why? I've some Custom Composables like
HeaderText
which used to have first parameter the text itself so I didn't need to write parameter names explicitly, but putting modifier as first parameter makes me lose this power.
a

Adam Powell

12/24/2020, 8:18 PM
First optional as in, you can still have the (required) text of a
HeaderText
come first. The intent of the guideline is that you can always supply a modifier to a compose UI function without using named parameters, it always comes right after the last required parameter.
k

Kshitij Patil

12/24/2020, 9:12 PM
Okay, so if my Composable has all optional parameters, modifier should be first among them?
a

Adam Powell

12/24/2020, 11:43 PM
Yes
2 Views