getLength method

  1. @override
int getLength()
override

Implementation

@override
int getLength() {
  int v = (customColumnType == null
      ? lengths[type][_col]
      : columnTypeLength[customColumnType![_col]])!;
  if (v == 0) {
    int ye = yearEnd!;
    if (maxValue != null) ye = maxValue!.year;
    return ye - _yearBegin + 1;
  }
  if (v == 31) return _calcDateCount(value!.year, value!.month);
  int columnType = getColumnType(_col);
  switch (columnType) {
    case 3: // hour
      if ((minHour != null && minHour! >= 0) ||
          (maxHour != null && maxHour! <= 23)) {
        return (maxHour ?? 23) - (minHour ?? 0) + 1;
      }
      break;
    case 4: // minute
      if (minuteInterval != null && minuteInterval! > 1) {
        return v ~/ minuteInterval!;
      }
      break;
    case 7: // hour am/pm
      if ((minHour != null && minHour! >= 0) ||
          (maxHour != null && maxHour! <= 23)) {
        if (_colAP < 0) {
          // I don't know AM or PM
          return 12;
        } else {
          var min = 0;
          var max = 0;
          if (picker!.selecteds[_colAP] == 0) {
            // am
            min = minHour == null
                ? 1
                : minHour! >= 12
                    ? 12
                    : minHour! + 1;
            max = maxHour == null
                ? 12
                : maxHour! >= 12
                    ? 12
                    : maxHour! + 1;
          } else {
            // pm
            min = minHour == null
                ? 1
                : minHour! >= 12
                    ? 24 - minHour! - 12
                    : 1;
            max = maxHour == null
                ? 12
                : maxHour! >= 12
                    ? maxHour! - 12
                    : 1;
          }
          return max > min ? max - min + 1 : min - max + 1;
        }
      }
  }
  return v;
}