pageScrollStateChanges
Create a Flow of page scroll state change events on the ViewPager2 instance where the value emitted can be one of SCROLL_STATE_IDLE, SCROLL_STATE_DRAGGING} or SCROLL_STATE_SETTLING.
Note: Created flow keeps a strong reference to the ViewPager2 instance until the coroutine that launched the flow collector is cancelled.
Example of usage:
viewPager2.pageScrollStateChanges()
.onEach { state ->
// handle state
}
.launchIn(uiScope)
Content copied to clipboard