Hello! Is it possible to specify number of first i...
# compose
p
Hello! Is it possible to specify number of first invisible items that need to be precomposed for LazyColumn (Row)?
s
Can you explain this a little? From what I understand, you can give your @Preview composable its own custom size if need be. For example:
Copy code
@Preview(device = "spec:width=1200px,height=1600px,dpi=190")
@Composable
fun MyComposablePreview() {
  LazyColumn {
    item {
      Text("Some text")
    }
  }
}
But it doesn't have to do anything with LazyColumn specifically
p
No. May be I choose wrong word for it. I need LazyColumn pre compose first N invisible items from top and bottom.
t
kind of like how
HorizontalPager
can be encouraged to compose off screen stuff with the
beyondBoundsPageCount
parameter? Is that the effect you're looking for, but with LazyLists?
s
It is not possible to customize prefetch at the moment, but we are looking into prefetcher APIs in the future. Also note that prefetched item is not guaranteed to be created, it is purely a performance optimization. This is different from
beyondBoundsPageCount
which extends active range of
Pager
to include invisible items.
s
Maybe as a workaround for now, you could try putting Columns that accept n-number of items, inside your LazyColumn Since every Column will be treated as a single item, at least a single item will have to be fetched on screen.
a
HI @shikasd will this prefetcher api also work with
LazyColoumn
, and other
LazyXxx
apis? I need to prefetch some items to have perf optimisation similar to Recycler view
s
Eventually, yes Currently only lazy column/row are implemented
a
In which release they became available? How to set the item to prefetch? I tried
androidx.compose:compose-bom:2024.04.01
but couldn’t access anything
s
1.7 onwards, it is still in alpha