Is there an empty element in compose?
# compose
a
Is there an empty element in compose?
n
Not sure if it fits what you want but it the seems the most "empty" element is the Box
a
That is what I had in mind
I guess there are several solutions
r
Maybe the
Spacer
?
a
So
Spacer(Modifier)
n
you can just check the code of both, Box :
Copy code
@Composable
fun Box(modifier: Modifier) {
    Layout({}, measurePolicy = EmptyBoxMeasurePolicy, modifier = modifier)
}
Spacer:
Copy code
@Composable
fun Spacer(modifier: Modifier) {
    Layout({}, modifier) { _, constraints ->
        with(constraints) {
            val width = if (hasFixedWidth) maxWidth else 0
            val height = if (hasFixedHeight) maxHeight else 0
            layout(width, height) {}
        }
    }
}
👍 1
a
thanks
p
I tend to use
Unit
a
Great thanks!