DatePickerModel constructor
DatePickerModel()
Implementation
DatePickerModel({
DateTime? currentTime,
DateTime? maxTime,
DateTime? minTime,
List<String>? formats,
List<bool>? labels,
List<int>? weights,
List<String>? dividers,
}) : assert(weights == null || weights.length == 3),
assert(dividers == null || dividers.length == 2),
assert(formats == null || formats.length == 3),
assert(labels == null || labels.length == 3) {
this.weights = weights ?? [1, 1, 1];
this.dividers = dividers ?? ['', ''];
this.labels = labels ?? [true, true, true];
this.formats = formats ?? [yyyy, MM, dd];
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;
_fillYearList();
_fillMonthList();
_fillDayList();
int minMonth = _minMonthOfCurrentYear();
int minDay = _minDayOfCurrentMonth();
firstIndex = this.currentTime.year - this.minTime.year;
secondIndex = this.currentTime.month - minMonth;
thirdIndex = this.currentTime.day - minDay;
}