It appears that having multiple children under `Su...
# compose
f
It appears that having multiple children under
Surface
crashes the app
May be because I have an old version
a
yeah, probably you are getting IllegalStateException("Surface can have only one direct measurable child!"), right?
f
No error, the app just closes
a
I mean in logs you can see this error message
Anyway, yes, it is intended behavior now. Some of the layout components would assume they have at most one layout children, including Surface. I also would suggest you to not use Surface directly but, for example, Card. Then you are add inside a layout you need like Column or Row
We will work more on how we can communicate better about this limitation later. For example studio would suggest that you can't add two child Layouts inside such types of Layouts of so
f
Are you planning to add a
@Child
(singular
Children
) annotation to make this a compile-time error?
That's the way Flutter does it (conceptually)
a
we plan to add something to solve it. not sure about the exact way
f
Oh, I can see the error now
l
ideally we make this a compile-time error, yes. this is a bit harder to do for us than flutter because of our API, but something we are keeping in mind. I believe once we have proper inferencing for composables that this might fall out, but i’m not sure
i’m also wanting us to think deeper about whether or not this is a real requirement we want to keep for some of these material components, but i haven’t looked at why we actually have these constraints yet
f
The thing that came into my mind is direction
Do we lay it out as a column or a row?
You could default it to a column, I think that's how it is in HTML
l
yeah
another option is to just layout absolutely by default, and only stack vertical/horizontal if you specify
f
What do you mean by "absolutely"?
a
like FrameLayout does probably. but with top left gravity everytime