https://kotlinlang.org logo
f

Fudge

05/17/2019, 3:10 PM
It appears that having multiple children under
Surface
crashes the app
May be because I have an old version
a

Andrey Kulikov

05/17/2019, 3:23 PM
yeah, probably you are getting IllegalStateException("Surface can have only one direct measurable child!"), right?
f

Fudge

05/17/2019, 3:30 PM
No error, the app just closes
a

Andrey Kulikov

05/17/2019, 3:40 PM
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

Fudge

05/17/2019, 3:45 PM
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

Andrey Kulikov

05/17/2019, 3:46 PM
we plan to add something to solve it. not sure about the exact way
f

Fudge

05/17/2019, 4:11 PM
Oh, I can see the error now
l

Leland Richardson [G]

05/17/2019, 4:12 PM
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

Fudge

05/17/2019, 4:13 PM
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

Leland Richardson [G]

05/17/2019, 4:23 PM
yeah
another option is to just layout absolutely by default, and only stack vertical/horizontal if you specify
f

Fudge

05/17/2019, 4:25 PM
What do you mean by "absolutely"?
a

Andrey Kulikov

05/17/2019, 4:29 PM
like FrameLayout does probably. but with top left gravity everytime
4 Views