I am a newbie to Jetpack Compose, and I want to rebuild my old project, which was built several years ago, completely in Jetpack Compose.
And I have a date range picker that uses the MaterialDatePicker.
However, when I tried to build the date picker in my new compose project, it was more difficult than I thought and I can't find many articles about it.
All I can find is this one: https://androidexample365.com/date-pickers-let-users-select-range-of-dates-written-in-jetpack-compose/
Unfortunately, it is not using the Gregorian calendar and has a little bug, which will suddenly crash when you scroll to some date.
After 2 weeks fighting with the date picker, I still can't fix it.
Could anyone provide a library or an example project like the MaterialDatePicker?
The Material3 DateRangePicker is being worked on right now, so it will be the official answer in the future. I'd recommend waiting until it's included in at least an alpha release of the Material3 library (you can track releases here), but you can view the source if you want to get started with it sooner. Usage is pretty simple:
val state = rememberDateRangePickerState()
DateRangePicker(state = state)
When the user makes selections, the state.selectedStartDateMillis
and state.selectedEndDateMillis
values with be updated accordingly.