getCurrentListIndex static method

int getCurrentListIndex(
  1. SelectionEntity? currentItem
)

确定当前 Item 在第几层级

Implementation

static int getCurrentListIndex(SelectionEntity? currentItem) {
  int listIndex = -1;
  if (currentItem != null) {
    listIndex = 0;
    var parent = currentItem.parent;
    while (parent != null) {
      listIndex++;
      parent = parent.parent;
    }
  }
  return listIndex;
}