buildItem method

  1. @override
Widget buildItem(
  1. BuildContext context,
  2. int index
)
override

Implementation

@override
Widget buildItem(BuildContext context, int index) {
  String text = "";
  int colType = getColumnType(_col);
  switch (colType) {
    case 0:
      if (twoDigitYear) {
        text = "${_yearBegin + index}";
        var txtLength = text.length;
        text =
            "${text.substring(txtLength - (txtLength - 2), txtLength)}${_checkStr(yearSuffix)}";
      } else {
        text = "${_yearBegin + index}${_checkStr(yearSuffix)}";
      }
      break;
    case 1:
      if (isNumberMonth) {
        text = "${index + 1}${_checkStr(monthSuffix)}";
      } else {
        if (months != null) {
          text = months![index];
        } else {
          List months =
              PickerLocalizations.of(context).months ?? monthsListEN;
          text = "${months[index]}";
        }
      }
      break;
    case 2:
      text = "${index + 1}${_checkStr(daySuffix)}";
      break;
    case 3:
      text = "${intToStr(index + (minHour ?? 0))}${_checkStr(hourSuffix)}";
      break;
    case 5:
      text = "${intToStr(index)}${_checkStr(secondSuffix)}";
      break;
    case 4:
      if (minuteInterval == null || minuteInterval! < 2) {
        text = "${intToStr(index)}${_checkStr(minuteSuffix)}";
      } else {
        text =
            "${intToStr(index * minuteInterval!)}${_checkStr(minuteSuffix)}";
      }
      break;
    case 6:
      final apStr = strAMPM ??
          PickerLocalizations.of(context).ampm ??
          const ['AM', 'PM'];
      text = "${apStr[index]}";
      break;
    case 7:
      text = intToStr(index +
          (minHour == null
              ? 0
              : (picker!.selecteds[_colAP] == 0 ? minHour! : 0)) +
          1);
      break;
  }

  final isSel = picker!.selecteds[_col] == index;
  if (picker!.onBuilderItem != null) {
    var v = picker!.onBuilderItem!(context, text, null, isSel, _col, index);
    if (v != null) return makeText(v, null, isSel);
  }
  return makeText(null, text, isSel);
}