ButtonGroupState
sealed interface ButtonGroupState : ScrollableState
A state object that allows querying and controlling the state of a ButtonGroup component.
Summary
Public companion properties |
|
|---|---|
Saver<ButtonGroupState, Int> |
The default |
Public functions |
|
|---|---|
suspend Unit |
animateScrollToItem(Scroll to the item at |
suspend Unit |
scrollToItem(index: Int)Jump instantly to the item at |
Public properties |
|
|---|---|
Int |
Index of the current child. |
Int |
The number of items currently within the ButtonGroup. |
Inherited functions |
||||
|---|---|---|---|---|
|
Inherited properties |
|---|
Public companion properties
Saver
val Saver: Saver<ButtonGroupState, Int>
The default Saver implementation for ButtonGroupState.
Public functions
animateScrollToItem
suspend fun animateScrollToItem(
index: Int,
animationSpec: FiniteAnimationSpec<Float> = ButtonGroupDefaults.AnimateScrollToItemAnimationSpec
): Unit
Scroll to the item at index with the given animationSpec.
If the ButtonGroup has focus, focus will be requested for the child at this index.
| Throws | |
|---|---|
IllegalArgumentException |
if |
scrollToItem
suspend fun scrollToItem(index: Int): Unit
Jump instantly to the item at index.
If the ButtonGroup has focus, focus will be requested for the child at this index.
| Throws | |
|---|---|
IllegalArgumentException |
if |
Public properties
currentItemIndex
val currentItemIndex: Int
Index of the current child.
The index updates continuously as the user scrolls. To get updates only when the index is "settled", use the current item index when isScrollInProgress is false.
Returns -1 if the ButtonGroup is empty, or if the layout has not been initialized yet.
itemCount
val itemCount: Int
The number of items currently within the ButtonGroup.