rememberDatePickerState

fun rememberDatePickerState(initialDate: LocalDate = currentDate()): DatePickerState

Creates and remembers a DatePickerState. Initial date values are read when the state is first created.

Return

A DatePickerState initialized with initialDate.

Parameters

initialDate

The initial date to be selected. Defaults to the current date.


fun rememberDatePickerState(items: DatePickerItems, initialDate: LocalDate = currentDate()): DatePickerState

Creates and remembers a DatePickerState whose initial value is coerced by items.

Initial values and items are read when the state is first created. On recreation, the items supplied by the recreated composition also coerce the saved value, so the picker cannot restore outside its current custom lists or date bounds.

Return

A DatePickerState initialized to the closest selectable date.

Parameters

items

Selectable values used to coerce initialDate before creating the state.

initialDate

The requested initial date.

Throws

if the configured item lists are invalid or contain no date allowed by their constraints.


fun rememberDatePickerState(items: DatePickerItems, initialYear: Int, initialMonth: Int, initialDay: Int): DatePickerState

Creates and remembers a DatePickerState whose explicit initial date parts are coerced by items.

Initial values and items are read when the state is first created. If initialDay is greater than the maximum day for initialYear and initialMonth, it is clamped before applying items. On recreation, the items supplied by the recreated composition also coerce the saved value.

Return

A DatePickerState initialized to the closest selectable date.

Parameters

items

Selectable values used to coerce initialYear, initialMonth, and initialDay.

initialYear

The requested initial year. Must be in 1000..9999.

initialMonth

The requested initial month. Must be in 1..12.

initialDay

The requested initial day. Must be at least 1.

Throws

if an initial date part is outside its supported range, or if the configured item lists are invalid or contain no date allowed by their constraints.


fun rememberDatePickerState(initialYear: Int, initialMonth: Int, initialDay: Int): DatePickerState

Creates and remembers a DatePickerState with explicit year, month, and day values.

Initial values are read only when the state is first created.

Return

A DatePickerState initialized with the given date values.

Parameters

initialYear

The initial year to be selected. Must be in 1000..9999.

initialMonth

The initial month to be selected. Must be in 1..12.

initialDay

The initial day to be selected. Must be at least 1.