DateTimePickerAdapter constructor
DateTimePickerAdapter({
- Picker? picker,
- int type = 0,
- bool isNumberMonth = false,
- List<
String> ? months = MonthsList_EN, - List<
String> ? strAMPM, - int? yearBegin = 1900,
- int? yearEnd = 2100,
- DateTime? value,
- DateTime? minValue,
- DateTime? maxValue,
- int? minHour,
- int? maxHour,
- String? secondSuffix,
- String? minuteSuffix,
- String? hourSuffix,
- String? yearSuffix,
- String? monthSuffix,
- String? daySuffix,
- int? minuteInterval,
- List<
int> ? customColumnType, - bool twoDigitYear = false,
Implementation
DateTimePickerAdapter({
Picker? picker,
this.type = 0,
this.isNumberMonth = false,
this.months = MonthsList_EN,
this.strAMPM,
this.yearBegin = 1900,
this.yearEnd = 2100,
this.value,
this.minValue,
this.maxValue,
this.minHour,
this.maxHour,
this.secondSuffix,
this.minuteSuffix,
this.hourSuffix,
this.yearSuffix,
this.monthSuffix,
this.daySuffix,
this.minuteInterval,
this.customColumnType,
this.twoDigitYear = false,
}) : assert(minuteInterval == null ||
(minuteInterval >= 1 &&
minuteInterval <= 30 &&
(60 % minuteInterval == 0))) {
super.picker = picker;
_yearBegin = yearBegin ?? 0;
if (minValue != null && minValue!.year > _yearBegin) {
_yearBegin = minValue!.year;
}
// Judge whether the day is in front of the month
// If in the front, set "needUpdatePrev" = true
List<int> _columnType;
if (customColumnType != null)
_columnType = customColumnType!;
else
_columnType = columnType[type];
var month = _columnType.indexWhere((element) => element == 1);
var day = _columnType.indexWhere((element) => element == 2);
_needUpdatePrev =
day < month || day < _columnType.indexWhere((element) => element == 0);
if (!_needUpdatePrev) {
// check am/pm before hour-ap
var ap = _columnType.indexWhere((element) => element == 6);
if (ap > _columnType.indexWhere((element) => element == 7)) {
_apBeforeHourAp = true;
_needUpdatePrev = true;
}
}
if (value == null) {
value = DateTime.now();
}
_existSec = existSec();
_verificationMinMaxValue();
}