Is it possible to change the modifier of a composa...
# compose
r
Is it possible to change the modifier of a composable as parameter (
Content: @Composable () -> Unit
)? Right now I'm wrapping it in a
Box
to be able to set my modifier but I was wondering if there is a better way:
Copy code
Box(modifier = modifier) {
      content()
}
s
You could pass a
Modifier
as the only parameter of
content
, but then the user would have to "remember" to use it
z
This is probably mostly an API concern - forcing your callers to apply a modifier you give them is very error-prone (see how often people report
Scaffold
bugs). Wrapping in a box is cheap, Box is inline and designed for this sort of thing. One important note however is that you'll want to pass
propagateMinConstraints=true
when doing so, otherwise you'll eg break if someone passes you a
fillMaxSize
👍 2