Hello, I'm trying to scroll a LazyColumn to a specific index and offset using Launched Effect. Is this safe or could there be timing issue where request to scroll is processed earlier than the layout/draw phase?
Sam
11/03/2024, 5:50 PM
Copy code
@Composable
private fun ScrollableList(
items: List<Int>,
scrollTo: Int,
scrollToOffset: Int,
modifier: Modifier = Modifier
) {
val state = rememberLazyListState()
// Can this happen before list's layout/draw?
LaunchedEffect(state, scrollTo) {
state.scrollToItem(scrollTo, scrollToOffset)
}
LazyColumn(
state = state,
modifier = modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
...
}
}