*When using the `Layout()` composable is there a w...
# compose
j
When using the
Layout()
composable is there a way to somehow group the `measurables`/`placeables` by some property of my data model?
I’m trying to create a custom layout composable which places its children according to some property of the data model from which the children themselves are created. But from within the
Layout()
block the children are exposed as `measurable`/`placeable` so there is no visibility into their props. Is there a way to pass any property from my data model or from the child composables into their respective measurables/placeables? Or any other way to achieve this (e.g. meta-data or anything else)?
1
a
You can use
Modifier.layoutId()
or
ParentDataModifier
.
1
j
Can I pass any object into
Modifier.layoutId()
? I mean it’s not stuff that must be able to go in bundles/parcelables? Can I just pass in there a reference to a huge data class?
By “Using
ParentDataModifier
” do you mean to create my own modifier instead of using
Modifier.layoutId()
?
n
I think it will go in the semantics (meaning it's extracted as "info" of your composable, which can be seen in layout inspector and such") so I think I would avoid this for a layoutId for the ParentDataModifier -> https://fvilarino.medium.com/creating-a-custom-modifier-attribute-on-jetpack-compose-f100c6bcb987
🙏 1
a
Can I pass any object into Modifier.layoutId() ?
Yes you can pass any object.
By “Using ParentDataModifier ” do you mean to create my own modifier instead of using Modifier.layoutId() ?
Yes.
🙏 1