How a composable lambda would validate or accept o...
# compose
k
How a composable lambda would validate or accept only one composable or a list of composable. In flutter we can decide to accept a single widget or list of widget for children or child parameter
a
A composable function is not a single widget, it's a part of a composition which might emit 0-N tree nodes. If you want to affect a single layout node, you probably want a modifier.
What kind of abstraction are you looking to create?
y
You would probably need to collect the content of your lambda in a layout, and then check that it only has 1 child and if not throw an exception. I'm guessing that's what
Surface
is doing to ensure it only has one child. You can take a look at the
Surface
composable source code to check how they did it.
a
fwiw that behavior of Surface is a bug on the list to be addressed, not a desirable behavior 🙂
don't emulate it
y
Nice to know thanks. I think a lint error with a custom annotation shouldn't be too complicated to code if he wants something static edit: nvm, some control flow may make this more complicated than I thought
k
Thanks @Adam Powell just curious on how things working under the hood