https://kotlinlang.org logo
Title
s

Stefan Oltmann

07/01/2022, 7:04 AM
To reduce GC I want to have a static instance of
Modifier.weight(1.0f)
I have this extension function:
@Composable
fun ColumnScope.FillSpacer(): Unit = Spacer(Modifier.weight(1.0f))
Now I try to figure out how I can define my
val
for that. I find it a bit tricky because of the ColumnScope.
a

Adam Powell

07/01/2022, 12:59 PM
Technically a future version of the compose libraries could implement weight in such a way that the underlying modifier returned can't be reused and is bound to the parent column instance, so you can't really accomplish what you're trying to do robustly and safely. Honestly though, it's probably not worth trying. What you've already written here is skippable in recomposition and it's going to allocate more objects than the modifier in initial composition anyway
s

Stefan Oltmann

07/01/2022, 6:37 PM
Ok, thank you.