Hi guys! I’ve a `LazyColumn` with `stickyHeader` a...
# compose
g
Hi guys! I’ve a
LazyColumn
with
stickyHeader
and
itemsIndexed
. To build it I’m using
.forEach { (header, data) ->
. Let’s say I would have a “today” button, how can I scroll to a desired
stickyHeader
position making it the first item visible? As far as i know I don’t have access to
stickyHeader
indexes 🤔
o
I would create a map (header-to-index) and fill it in the
content
lambda of the LazyColumn. Just create a variable “index” with 0 initial value and increment it with each item/header added. When adding header with
stickyHeader
, also add an entry to your map and use current “index” value. It should be safe to increment stuff in
content
lambda, as it is not in
Composable
scope.
g
Nice suggestion! I’ll try that, thanks!