setColumn method

  1. @override
void setColumn(
  1. int index
)
override

Sets the active column for subsequent operations.

This method is called before getLength and buildItem to specify which column is being processed. The index is typically 0-based.

Parameters:

  • index - The column index to activate

Implementation

@override
void setColumn(int index) {
  if (_datas != null && _col == index + 1) return;
  _col = index + 1;
  if (isArray) {
    // ignore: avoid_print
    if (picker!.printDebug) print("index: $index");
    if (_col < data.length) {
      _datas = data[_col].children;
    } else {
      _datas = null;
    }
    return;
  }
  if (index < 0) {
    _datas = data;
  } else {
    _datas = data;
    // Too many columns will have performance issues
    for (int i = 0; i <= index; i++) {
      var j = picker!.selecteds[i];
      if (_datas != null && _datas!.length > j) {
        _datas = _datas![j].children;
      } else {
        _datas = null;
        break;
      }
    }
  }
}