level method

int level()

Implementation

int level() {
  int maxLevel = 1;
  int treeDeep(List<CityModel> items) {
    int currentLevel = 1;
    for (var item in items) {
      if (item.children != null) {
        currentLevel = 1 + treeDeep(item.children);
      }
    }
    return currentLevel;
  }

  for (var item in records) {
    int level = 1 + treeDeep(item.children);
    if (level > maxLevel) {
      maxLevel = level;
    }
  }
  print("== max tree level ==" + maxLevel.toString());
  return maxLevel;
}