Alexandru Gheorghe
05/27/2024, 10:16 AMStylianos Gakis
05/27/2024, 4:59 PMAlexandru Gheorghe
05/28/2024, 9:51 AMLazyListState.firstVisibleItemIndex
and I am unable to get a behavior where if a user flings between Cards composables in the LazyRow the code will execute at each fling using LazyListState.firstVisibleItemIndex
- any thoughts where I can execute the code? Within the LazyRow body before calling the Card composable? If so, how do I detect when the user has changed the state by flinging to a different Card composable to thus execute the code? I guess it has to be done in a way that triggers recomposition so a state needs to be kept.Stylianos Gakis
05/28/2024, 9:56 AMval lazyListState = rememberLazyListState()
LaunchedEffect(lazyListState) {
snapshotFlow { lazyListState.firstVisibleItemIndex }
.collect { firstVisibleItemIndex ->
println(firstVisibleItemIndex)
}
}
If you do this, do you get emissions on each time the firstVisibleItemIndex
changes?Alexandru Gheorghe
05/28/2024, 10:09 AM@Composable invocations can only happen from the context of a @Composable function
should I run outside of it? the caller would still be a ComposableAlexandru Gheorghe
05/28/2024, 10:17 AMfirstVisibleItemIndex
being logged when I fling between Cards in the LazyRow.Alexandru Gheorghe
05/28/2024, 10:24 AMStylianos Gakis
05/28/2024, 10:31 AMAlexandru Gheorghe
05/28/2024, 10:34 AMAlexandru Gheorghe
05/28/2024, 10:35 AMStylianos Gakis
05/28/2024, 10:55 AMAlexandru Gheorghe
05/28/2024, 12:05 PMAlexandru Gheorghe
05/28/2024, 12:20 PMAlexandru Gheorghe
05/28/2024, 12:35 PMStylianos Gakis
05/28/2024, 2:25 PMStylianos Gakis
05/28/2024, 2:26 PMAlexandru Gheorghe
05/28/2024, 2:27 PMStylianos Gakis
05/28/2024, 2:34 PMAlexandru Gheorghe
05/28/2024, 3:21 PMStylianos Gakis
05/28/2024, 3:26 PM