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

Kshitij Patil

02/03/2021, 9:47 AM
I want to group two related components that are part of ConstraintLayout to a separate
@Composable
function. Currently I was planning to borrow the constraints from parent layout through
Modifier
type parameter.
Copy code
@Composable
fun CustomGroup(
    <required-fields>,
    ...,
    firstComponentModifier: Modifier = Modifier,
    secondComponentModifier: Modifier = Modifier,
    ...,
    <other optional fields>
) { ... }
This seems to be working for me but the linter gives this error warning: “Modifier parameter should be named modifier”. I think my use-case is valid and we shouldn’t restrict modifier name to be modifier only or we should make
ConstrainedLayoutReferences
class public so that I could pass it on as parameter to other function
a

allan.conda

02/03/2021, 9:55 AM
error or warning? You can just supress it
k

Kshitij Patil

02/03/2021, 10:25 AM
Yeah it was warning but I felt that warning itself is not necessary or I’d like to know why is it so?
c

Cyril Find

02/03/2021, 11:17 AM
We might be missing some context here but I think it’s more “compose” to pass both your Composables as parameters instead of the modifiers
f

fmasa

02/03/2021, 12:28 PM
Well, even Compose itself uses multiple modifiers on some places. I think it's completely fine to suppress the warning just like in i.e.
DropdowMenu
.
a

Adam Powell

02/03/2021, 2:20 PM
Which part of
ConstrainedLayoutReferences
isn't public?