DateTimePickerAdapter constructor

DateTimePickerAdapter({
  1. Picker? picker,
  2. int type = 0,
  3. bool isNumberMonth = false,
  4. List<String>? months = MonthsList_EN,
  5. List<String>? strAMPM,
  6. int? yearBegin = 1900,
  7. int? yearEnd = 2100,
  8. DateTime? value,
  9. DateTime? minValue,
  10. DateTime? maxValue,
  11. int? minHour,
  12. int? maxHour,
  13. String? secondSuffix,
  14. String? minuteSuffix,
  15. String? hourSuffix,
  16. String? yearSuffix,
  17. String? monthSuffix,
  18. String? daySuffix,
  19. int? minuteInterval,
  20. List<int>? customColumnType,
  21. 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();
}