setDateAndAnimate method

void setDateAndAnimate(
  1. DateTime date, {
  2. dynamic duration = const Duration(milliseconds: 500),
  3. dynamic curve = Curves.linear,
})

This function will animate to any date that is passed as an argument this will also set that date as the current selected date

Implementation

void setDateAndAnimate(DateTime date,
    {duration = const Duration(milliseconds: 500), curve = Curves.linear}) {
  assert(
    _monthTimelineState != null,
    'YearTimelineController is not attached to any DatePicker View.',
  );

  _monthTimelineState!._controller.animateTo(_calculateDateOffset(date),
      duration: duration, curve: curve);

  if (date.compareTo(_monthTimelineState!.widget.startDate) >= 0 &&
      date.compareTo(
            _monthTimelineState!.widget.startDate.add(
              Duration(
                days: _monthTimelineState!.widget.yearCount,
              ),
            ),
          ) <=
          0) {
    // date is in the range
    _monthTimelineState!._currentDate = date;
  }
}