pullRefresh
Source set: Common
public fun Modifier.pullRefresh(state: PullRefreshState, enabled: Boolean = true): Modifier
pullRefresh
Source set: Common
public fun Modifier.pullRefresh(
onPull: (pullDelta: Float) -> Float,
onRelease: suspend (flingVelocity: Float) -> Float,
enabled: Boolean = true,
): Modifier
A nested scroll modifier that provides onPull and onRelease callbacks to aid building custom pull refresh components.
Note that this modifier must be added above a scrolling container, such as a lazy column, in order to receive scroll events. For example:
Parameters
| onPull | Callback for dispatching vertical scroll delta, takes float pullDelta as argument. Positive delta (pulling down) is dispatched only if the child does not consume it (i.e. pulling down despite being at the top of a scrollable component), whereas negative delta (swiping up) is dispatched first (in case it is needed to push the indicator back up), and then the unconsumed delta is passed on to the child. The callback returns how much delta was consumed. |
| onRelease | Callback for when drag is released, takes float flingVelocity as argument. The callback returns how much velocity was consumed - in most cases this should only consume velocity if pull refresh has been dragged already and the velocity is positive (the fling is downwards), as an upwards fling should typically still scroll a scrollable component beneath the pullRefresh. This is invoked before any remaining velocity is passed to the child. |
| enabled | If not enabled, all scroll delta and fling velocity will be ignored and neither onPull nor onRelease will be invoked. |