DateRangePickerState
@ExperimentalMaterial3Api
interface DateRangePickerState
A state object that can be hoisted to observe the date range picker state. See
rememberDateRangePickerState
.
Properties
val selectedStartDateMillis: Long?
A timestamp that represents the selected start date start of the day in UTC milliseconds from the epoch.
val selectedEndDateMillis: Long?
A timestamp that represents the selected end date start of the day in UTC milliseconds from the epoch.
var displayedMonthMillis: Long
A timestamp that represents the currently displayed month start date in UTC milliseconds from the epoch.
var displayMode: DisplayMode
A DisplayMode
that represents the current UI mode (i.e. picker or input).
val yearRange: IntRange
An IntRange
that holds the year range that the date picker will be limited to.
val selectableDates: SelectableDates
A SelectableDates
that is consulted to check if a date is allowed.
In case a date is not allowed to be selected, it will appear disabled in the UI.
val locale: CalendarLocale
A locale that will be used when formatting dates, determining the input format, week-days, and more.
Functions
fun setSelection(
@Suppress("AutoBoxing") startDateMillis: Long?,
@Suppress("AutoBoxing") endDateMillis: Long?,
)
Sets a start and end selection dates.
The function expects the dates to be within the state's year-range, and for the start date to
appear before, or be equal, the end date. Also, if an end date is provided (e.g. not null
),
a start date is also expected to be provided. In any other case, an
IllegalArgumentException
is thrown.
Parameters
startDateMillis | timestamp in UTC milliseconds from the epoch that represents the start date selection. Provide a null to indicate no selection. |
endDateMillis | timestamp in UTC milliseconds from the epoch that represents the end date selection. Provide a null to indicate no selection. |