I have noticed some composables have a content fie...
# compose
m
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
and they also have a body for content
What do you mean?
r
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
(trailing lambda)
a
ah so that’s what he meant, 😄
😄 2
m
@romainguy so all composables we write inside the body of other composables are made possible thanks to trailing lambdas?
m
Yes, the "body" of the composable is possible and equal to the last parameter of this composable is a lambda https://kotlinlang.org/docs/reference/lambdas.html#passing-a-lambda-to-the-last-parameter
❤️ 1
c