androidx.compose.material3

SwipeToDismissBoxState

Class

No hand-written docs yet.

State of the SwipeToDismissBox composable.

class SwipeToDismissBoxState

How to get one

Ready-made values and functions that return it

Used by

Parameters that take a SwipeToDismissBoxState.

Properties

currentValue

val currentValue: SwipeToDismissBoxValue

The current state value of the SwipeToDismissBoxState.

targetValue

val targetValue: SwipeToDismissBoxValue

The target state. This is the closest state to the current offset (taking into account positional thresholds). If no interactions like animations or drags are in progress, this will be the current state.

settledValueSince 1.9

val settledValue: SwipeToDismissBoxValue

The value the SwipeToDismissBoxState is currently settled at. When progressing through multiple anchors, e.g. A -> B -> C, settledValue will stay the same until settled at an anchor, while currentValue will update to the closest anchor.

progress

val progress: Float

The fraction of the progress going from currentValue to targetValue, within [0f..1f] bounds.

dismissDirection

val dismissDirection: SwipeToDismissBoxValue

The direction (if any) in which the composable has been or is being dismissed.

Functions

requireOffset

fun requireOffset(): Float

Require the current offset.

snapTo

fun snapTo(targetValue: SwipeToDismissBoxValue)

Set the state without any animation and suspend until it's set

reset

fun reset(): AnimationResult<T, V>

Reset the component to the default position with animation and suspend until it if fully reset or animation has been cancelled. This method will throw CancellationException if the animation is interrupted

dismiss

fun dismiss(direction: SwipeToDismissBoxValue)

Dismiss the component in the given direction, with an animation and suspend. This method will throw CancellationException if the animation is interrupted

Saver

fun Saver(
    positionalThreshold: (totalDistance: Float) -> Float,
): Saver

The default Saver implementation for SwipeToDismissBoxState.

Library docs

State of the SwipeToDismissBox composable.