Composable Component

PullToRefreshBox

PullToRefreshBox is a container that expects a scrollable layout as content and adds gesture support for manually refreshing when the user swipes downward at the beginning of the content.

PullToRefreshBox is a container that expects a scrollable layout as content and adds gesture support for manually refreshing when the user swipes downward at the beginning of the content. By default, it uses PullToRefreshDefaults.Indicator as the refresh indicator, but you may also choose to set your own indicator or use PullToRefreshDefaults.LoadingIndicator.

PullToRefreshBox

Common
@Composable
fun PullToRefreshBox(
    isRefreshing: Boolean,
    onRefresh: () -> Unit,
    modifier: Modifier = Modifier,
    state: PullToRefreshState = rememberPullToRefreshState(),
    contentAlignment: Alignment = Alignment.TopStart,
    indicator: @Composable BoxScope.() -> Unit = {
        Indicator(
            modifier = Modifier.align(Alignment.TopCenter),
            isRefreshing = isRefreshing,
            state = state,
        )
    },
    enabled: Boolean = true,
    threshold: Dp = PullToRefreshDefaults.PositionalThreshold,
    content: @Composable BoxScope.() -> Unit,
)

Parameters

isRefreshing whether a refresh is occurring
onRefresh callback invoked when the user gesture crosses the threshold, thereby requesting a refresh.
modifier the Modifier to be applied to this container
state the state that keeps track of distance pulled
contentAlignment The default alignment inside the Box.
indicator the indicator that will be drawn on top of the content when the user begins a pull or a refresh is occurring
enabled whether nested scroll events should be consumed by this component
threshold how much distance can be scrolled down before onRefresh is invoked
content the content of the pull refresh container, typically a scrollable layout such as LazyColumn or a layout using androidx.compose.foundation.verticalScroll
Common
Deprecated Use the PullToRefreshBox that takes enabled and threshold parameters

PullToRefreshBox

@Composable
fun PullToRefreshBox(
    isRefreshing: Boolean,
    onRefresh: () -> Unit,
    modifier: Modifier = Modifier,
    state: PullToRefreshState = rememberPullToRefreshState(),
    contentAlignment: Alignment = Alignment.TopStart,
    indicator: @Composable BoxScope.() -> Unit = {
        Indicator(
            modifier = Modifier.align(Alignment.TopCenter),
            isRefreshing = isRefreshing,
            state = state,
        )
    },
    content: @Composable BoxScope.() -> Unit,
)