I have noticed some composables have a content field, and they also have a body for content. Should the children composables go in their content field or written in their body?
For example surface:
Copy code
@Composable
fun Surface(
modifier: Modifier = Modifier,
shape: Shape = RectangleShape,
color: Color = MaterialTheme.colors.surface,
contentColor: Color = contentColorFor(color),
border: Border? = null,
elevation: Dp = 0.dp,
content: @Composable () -> Unit
)
a
allan.conda
08/06/2020, 5:24 AM
and they also have a body for content
What do you mean?
r
romainguy
08/06/2020, 6:03 AM
When a lambda (content here) is the last parameter you can use a special Kotlin syntax so you can write
Surface { content() }
instead
❤️ 1
K 2
romainguy
08/06/2020, 6:03 AM
(trailing lambda)
a
allan.conda
08/06/2020, 6:10 AM
ah so that’s what he meant, 😄
😄 2
m
Mehdi Haghgoo
08/06/2020, 8:20 AM
@romainguy so all composables we write inside the body of other composables are made possible thanks to trailing lambdas?