DatePickerModel constructor

DatePickerModel({
  1. DateTime? currentTime,
  2. DateTime? maxTime,
  3. DateTime? minTime,
  4. LocaleType? locale,
})

Implementation

DatePickerModel(
    {DateTime? currentTime,
    DateTime? maxTime,
    DateTime? minTime,
    LocaleType? locale})
    : super(locale: locale) {
  this.maxTime = maxTime ?? DateTime(2049, 12, 31);
  this.minTime = minTime ?? DateTime(1970, 1, 1);

  currentTime = currentTime ?? DateTime.now();

  if (currentTime.compareTo(this.maxTime) > 0) {
    currentTime = this.maxTime;
  } else if (currentTime.compareTo(this.minTime) < 0) {
    currentTime = this.minTime;
  }

  this.currentTime = currentTime;

  _fillLeftLists();
  _fillMiddleLists();
  _fillRightLists();
  int minMonth = _minMonthOfCurrentYear();
  int minDay = _minDayOfCurrentMonth();
  _currentLeftIndex = this.currentTime.year - this.minTime.year;
  _currentMiddleIndex = this.currentTime.month - minMonth;
  _currentRightIndex = this.currentTime.day - minDay;
}