getSelectedValues method

  1. @override
List<T> getSelectedValues()
override

Implementation

@override
List<T> getSelectedValues() {
  List<T> items = [];
  var sLen = picker!.selecteds.length;
  if (isArray) {
    for (int i = 0; i < sLen; i++) {
      int j = picker!.selecteds[i];
      if (j < 0 ||
          data[i].children == null ||
          j >= data[i].children!.length) {
        break;
      }
      T val = data[i].children![j].value as T;
      if (val != null) {
        items.add(val);
      }
    }
  } else {
    List<PickerItem<dynamic>>? datas = data;
    for (int i = 0; i < sLen; i++) {
      int j = picker!.selecteds[i];
      if (j < 0 || j >= datas!.length) break;
      items.add(datas[j].value);
      datas = datas[j].children;
      if (datas == null || datas.isEmpty) break;
    }
  }
  return items;
}