-
Lexycon authored
This PR changes the material date picker behavior when changing the year so that it matches the native picker and the material component guideline. (#81547) See material component guideline for the date picker: [Material component date-picker behavior](https://m3.material.io/components/date-pickers/guidelines#1531a81f-4052-4a75-a20d-228c7e110156) See also: [Material components android discussion](https://github.com/material-components/material-components-android/issues/1723) When selecting another year in the native picker, the same day will be selected (by respecting the boundaries of the date picker). The current material date picker does not select any day when changing the year. This will lead to confusion if the user presses OK and the year does not get updated. So here is my suggestion: It will try to preselect the day like the native picker: - respecting the boundaries of the date picker (firstDate, lastDate) - changing from leapyear 29th february will set 28th february if not a leapyear is selected - only set the day if it is selectable (selectableDayPredicate) The calendar shown in the recording was setup with this parameters: ``` firstDate: DateTime(2016, DateTime.june, 9), initialDate: DateTime(2018, DateTime.may, 4), lastDate: DateTime(2021, DateTime.january, 15), ``` https://github.com/flutter/flutter/assets/13588771/3041c296-b9d0-4078-88cd-d1135fc343b3 Fixes #81547