Pick the fix
Rotating the screen restarts the paged list from the top and refetches page 1. Best fix?
Hint 1 of 1
Where are loaded pages kept?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Call .cachedIn(viewModelScope) on the pager flow in the ViewModel
Correct. Loaded pages are cached for the ViewModel's lifetime.
Why not the others?
- B Build the Pager inside the composable. That makes it worse: a new Pager per composition.
- C Increase pageSize. Fewer pages, same restart.
- D Use
collectAsStateinstead. Paging needs collectAsLazyPagingItems, and caching is the issue.