How to correctly add a composable on top of a `laz...
# compose
p
How to correctly add a composable on top of a
lazycolumn
before the items array? if I add before the
items()
call, it gives me this error:
@Composable invocations can only happen from the context of a @Composable function
s
Copy code
LazyColumn() {
  item { HereGoesYourFirstExtraItem() }
  //whatever you had before anyway
  //items(...).... or whatever
}
2
m
What @Stylianos Gakis put is correct. Just an explanation: LazyColumn deliberately DOES NOT take a composable lamba like Column does. As a result, you cannot directly add composables to it. Basically, due to the laziness, it needs you to give it lambda functions which will produce your composable output, instead of directly producing your composable output. That's what the "item", "items" and "stickyHeader" functions do, is they register a lambda function with the control telling it how to produce a particular item when it's needed.