hi all, just a quick question about using list.for...
# compose
a
hi all, just a quick question about using list.forEach inside a row or column to emit composables. i remember a while back it was recommended to not do this, and in fact it wasnt possible because calling a composable inside forEach would raise a compilation error as you were calling a Composable function inside a non-composable one. But now i've seen it be done in snippets online, and also there is no longer a compilation error (maybe there never was?) so my question is, is it ok to use? i dont always want to rely on lazy rows or columns if i dont have to, just unclear about the "best practice"
👍 1
c
I've been doing it for as long as I can remember. I think it's absolutely fine.
a
IIRC it has always been working (because
forEach
is an inline fun) and it’s totally ok to use it if you know that there won’t be many off-screen items.
f
And you could always just do
for (item in list) { ... }