Geert
07/27/2021, 8:36 AMmodifier = Modifier
.then(Modifier.padding(it))
.then(Modifier.fillMaxSize())
and
modifier = Modifier.padding(it).fillMaxSize()
iamthevoid
07/27/2021, 8:43 AMthen
yousefa2
07/27/2021, 8:44 AM.then
combines two modifiers and returns the combined one. here’s the code.
Modifier.padding
, here, is just a function that wraps the usage of .then
for paddingRob Meeuwisse
07/27/2021, 9:14 AM@Composable
fun MyButton(
onClick: () -> Unit,
caption: String,
modifier: Modifier = Modifier,
) {
Button(
onClick = onClick,
modifier = Modifier
.requiredHeight(48.dp)
.then(modifier) // allows the caller to override our default height
) {
Text(caption)
}
}
And contrast to this:
modifier = modifier.requiredHeight(48.dp) // the caller's requiredHeight modifier will be ignored