# rememberPullRefreshState

Common/All

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material/pullrefresh/PullRefreshState` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable @https://developer.android.com/reference/kotlin/androidx/compose/material/ExperimentalMaterialApi https://developer.android.com/reference/kotlin/androidx/compose/material/pullrefresh/rememberPullRefreshState.composable#rememberPullRefreshState(kotlin.Boolean,kotlin.Function0,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)( refreshing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, onRefresh: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, refreshThreshold: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp, refreshingOffset: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp )` Creates a `https://developer.android.com/reference/kotlin/androidx/compose/material/pullrefresh/PullRefreshState` that is remembered across compositions. | Cmn |

## Functions

### rememberPullRefreshState

Cmn Artifact: [androidx.compose.material:material](https://developer.android.com/jetpack/androidx/releases/compose-material) [View Source](https://cs.android.com/search?q=file:androidx/compose/material/pullrefresh/PullRefreshState.kt+function:rememberPullRefreshState) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.10.0)

```
@Composable
@ExperimentalMaterialApi
fun rememberPullRefreshState(
    refreshing: Boolean,
    onRefresh: () -> Unit,
    refreshThreshold: Dp = PullRefreshDefaults.RefreshThreshold,
    refreshingOffset: Dp = PullRefreshDefaults.RefreshingOffset
): PullRefreshState
```

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/material/pullrefresh/PullRefreshState` that is remembered across compositions.

Changes to `https://developer.android.com/reference/kotlin/androidx/compose/material/pullrefresh/package-summary#rememberPullRefreshState(kotlin.Boolean,kotlin.Function0,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` will result in `https://developer.android.com/reference/kotlin/androidx/compose/material/pullrefresh/PullRefreshState` being updated.

```kotlin
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.ListItem
import androidx.compose.material.Text
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier

val refreshScope = rememberCoroutineScope()
var refreshing by remember { mutableStateOf(false) }
var itemCount by remember { mutableStateOf(15) }

fun refresh() = refreshScope.launch {
    refreshing = true
    delay(1500)
    itemCount += 5
    refreshing = false
}

val state = rememberPullRefreshState(refreshing, ::refresh)

Box(Modifier.pullRefresh(state)) {
    LazyColumn(Modifier.fillMaxSize()) {
        if (!refreshing) {
            items(itemCount) { ListItem { Text(text = "Item ${itemCount - it}") } }
        }
    }

    PullRefreshIndicator(refreshing, state, Modifier.align(Alignment.TopCenter))
}
```

| Parameters |
|---|---|
| `refreshing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | A boolean representing whether a refresh is currently occurring. |
| `onRefresh: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The function to be called to trigger a refresh. |
| `refreshThreshold: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp = PullRefreshDefaults.RefreshThreshold` | The threshold below which, if a release occurs, `https://developer.android.com/reference/kotlin/androidx/compose/material/pullrefresh/package-summary#rememberPullRefreshState(kotlin.Boolean,kotlin.Function0,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)` will be called. |
| `refreshingOffset: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp = PullRefreshDefaults.RefreshingOffset` | The offset at which the indicator will be drawn while refreshing. This offset corresponds to the position of the bottom of the indicator. |