setDateAndAnimate method

void setDateAndAnimate(
  1. DateTime date, {
  2. Duration duration = const Duration(milliseconds: 500),
  3. Curve 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 In case a date is out of range nothing will happen

Implementation

void setDateAndAnimate(DateTime date,
    {Duration duration = const Duration(milliseconds: 500),
    Curve curve = Curves.linear}) {
  final state = _datePickerState;
  if (state == null) return;

  if (_indexOfDate(date) == null) return; // date is out of range

  state._setSelectedDate(date);
  // May be null when the picker isn't laid out yet — select without
  // scrolling in that case.
  _animateToOffset(_targetOffsetForDate(date), duration, curve);
}