To reduce GC I want to have a static instance of `...
# compose
s
To reduce GC I want to have a static instance of
Modifier.weight(1.0f)
I have this extension function:
Copy code
@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
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
Ok, thank you.