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

DrawerState

@Stable class DrawerState : SwipeableState<DrawerValue>
kotlin.Any
   ↳ androidx.compose.material.SwipeableState<androidx.compose.material.DrawerValue>
   ↳ androidx.compose.material.DrawerState

State of the ModalDrawerLayout composable.

Summary

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

State of the ModalDrawerLayout composable.

Public methods
Unit
close(onClosed: () -> Unit = null)

Close the drawer with an animation.

Unit
open(onOpened: () -> Unit = null)

Open the drawer with an animation.

Companion functions
Saver<DrawerState, DrawerValue>
Saver(clock: AnimationClockObservable, confirmStateChange: (DrawerValue) -> Boolean)

The default Saver implementation for DrawerState.

Inherited functions
Properties
Boolean

Whether the drawer is closed.

Boolean

Whether the drawer is open.

Inherited properties

Public constructors

<init>

DrawerState(
    initialValue: DrawerValue,
    clock: AnimationClockObservable,
    confirmStateChange: (DrawerValue) -> Boolean = { true })

State of the ModalDrawerLayout composable.

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

Public methods

close

fun close(onClosed: () -> Unit = null): Unit

Close the drawer with an animation.

Parameters
onClosed: () -> Unit = null Optional callback invoked when the drawer has finished closing.

open

fun open(onOpened: () -> Unit = null): Unit

Open the drawer with an animation.

Parameters
onOpened: () -> Unit = null Optional callback invoked when the drawer has finished opening.

Properties

isClosed

val isClosed: Boolean

Whether the drawer is closed.

isOpen

val isOpen: Boolean

Whether the drawer is open.

Companion functions

Saver

fun Saver(
    clock: AnimationClockObservable,
    confirmStateChange: (DrawerValue) -> Boolean
): Saver<DrawerState, DrawerValue>

The default Saver implementation for DrawerState.