Skip to content

WizardState

@Stable



class WizardState

Tracks which page of a Wizard is showing. Create via rememberWizardState.

Hoisting this is what lets a caller drive navigation itself - skipping a page whose answer is already known, or jumping back to the start after a failed submission - rather than being limited to the built-in buttons.

Properties

canGoBack

Whether there is a page before the current one.

currentIndex

Index of the page currently showing.

Functions

back

fun back()

Steps back one page, stopping at the first.

isLastPage

fun isLastPage(pageCount: Int): Boolean

Whether currentIndex is the final page of a wizard with pageCount pages.

moveTo

fun moveTo(index: Int)

Moves to index, sliding in the direction the move implies. A move to the current page does nothing.

next

fun next(pageCount: Int)

Advances one page, stopping at the last of pageCount.

reset

fun reset()

Returns to the first page. Worth calling when reopening a wizard whose state outlives one showing.