Hello :wave: Did anyone figure out how to add a Li...
# compose
d
Hello 👋 Did anyone figure out how to add a Live Template that adds
modifier: Modifier = Modifier
parameter to a composable function?
s
Yep adding a live template really is super straightforward, you should give it a try Here’s how I’ve done it in my case, so I write
modif
and press enter and get this entire thing unfolded, and the cursor ends up at the end it of. Copy paste friendly text:
modif
Default modifier for parameter list of a composable
modifier: Modifier = androidx.compose.ui.Modifier,$END$
👍 1
f
I always have a default Modifier in composbles, so I updated the
comp
live template to add it,
Copy code
@androidx.compose.runtime.Composable
fun $NAME$(modifier: androidx.compose.ui.Modifier = androidx.compose.ui.Modifier) {
    $END$
}
👍 1
s
Yes, that works too ^^ it's really easy to play with live templates so go crazy. I didn't integrate it in the
comp
template since you often also want composables that return values so they don't take in modifier, and I really hate having to remove things after using a live template as opposed to just using 2 live templates in the first place.