rememberStackState

Functions summary

StackState
@Composable
rememberStackState(initialTopItem: @IntRange(from = 0) Int)

Creates and remembers a StackState for a VerticalStack.

Functions

rememberStackState

@Composable
fun rememberStackState(initialTopItem: @IntRange(from = 0) Int = 0): StackState

Creates and remembers a StackState for a VerticalStack.

The returned StackState is remembered across compositions and can be used to control or observe the state of a VerticalStack. It's essential to pass this state to the state parameter of the corresponding VerticalStack composable.

Note: Properties of the state will only be correctly populated after the VerticalStack it is associated with has been composed for the first time.

Warning: A single StackState instance must not be shared across multiple VerticalStack composables.

Parameters
initialTopItem: @IntRange(from = 0) Int = 0

The index of the item to show at the top of the stack initially. Must be non-negative. Defaults to 0.