onDateChanged method

void onDateChanged(
  1. DateTime date
)

Called when the user selects a date in the calendar. If the startDate is null, it will be set to the date parameter. If the startDate is not null and the endDate is null, it will be set to the date parameter except if the date is before the startDate. In this case, the startDate will be set to the date parameter and the endDate will be set to null. If the startDate is not null and the endDate is not null, the startDate will be set to the date parameter and the endDate will be set to null.

Implementation

void onDateChanged(DateTime date) {
  print(date);
  startDate = date;
  endDate = date;
  // if (startDate == null) {
  //   startDate = date;
  //   onDateRangeChanged(DateRange(startDate!, startDate!));
  // } else if (endDate == null) {
  //   if (date.isBefore(startDate!)) {
  //     startDate = date;
  //     endDate = null;
  //   } else {
  //     endDate = date;
  onDateRangeChanged(DateRange(startDate!, endDate!));
  //   }
  // } else {
  //   startDate = date;
  //   endDate = null;
  // }
}