Google is committed to advancing racial equity for Black communities. See how.

DismissState

class DismissState : SwipeableState<DismissValue>
kotlin.Any
   ↳ androidx.compose.material.SwipeableState<androidx.compose.material.DismissValue>
   ↳ androidx.compose.material.DismissState

State of the SwipeToDismiss composable.

Summary

Public constructors
<init>(initialValue: DismissValue, clock: AnimationClockObservable, confirmStateChange: (DismissValue) -> Boolean = { true })

State of the SwipeToDismiss composable.

Public methods
Unit
dismiss(direction: DismissDirection, onDismissed: () -> Unit = null)

Dismiss the component in the given direction, with an animation.

Boolean

Whether the component has been dismissed in the given direction.

Unit
reset(onReset: () -> Unit = null)

Reset the component to the default position, with an animation.

Companion functions
Saver<DismissState, DismissValue>
Saver(clock: AnimationClockObservable, confirmStateChange: (DismissValue) -> Boolean)

The default Saver implementation for DismissState.

Inherited functions
Properties
DismissDirection?

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

Inherited properties

Public constructors

<init>

DismissState(
    initialValue: DismissValue,
    clock: AnimationClockObservable,
    confirmStateChange: (DismissValue) -> Boolean = { true })

State of the SwipeToDismiss composable.

Parameters
initialValue: DismissValue The initial value of the state.
clock: AnimationClockObservable The animation clock that will be used to drive the animations.
confirmStateChange: (DismissValue) -> Boolean = { true } Optional callback invoked to confirm or veto a pending state change.

Public methods

dismiss

fun dismiss(
    direction: DismissDirection,
    onDismissed: () -> Unit = null
): Unit

Dismiss the component in the given direction, with an animation.

Parameters
direction: DismissDirection The dismiss direction.
onDismissed: () -> Unit = null Optional callback invoked when the component has been dismissed.

isDismissed

fun isDismissed(direction: DismissDirection): Boolean

Whether the component has been dismissed in the given direction.

Parameters
direction: DismissDirection The dismiss direction.

reset

fun reset(onReset: () -> Unit = null): Unit

Reset the component to the default position, with an animation.

Parameters
onReset: () -> Unit = null Optional callback invoked when the component has been reset.

Properties

dismissDirection

val dismissDirection: DismissDirection?

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

If the composable is settled at the default state, then this will be null. Use this to change the background of the SwipeToDismiss if you want different actions on each side.

Companion functions

Saver

fun Saver(
    clock: AnimationClockObservable,
    confirmStateChange: (DismissValue) -> Boolean
): Saver<DismissState, DismissValue>

The default Saver implementation for DismissState.