sortChildrenZIndex method

  1. @override
void sortChildrenZIndex()
override

Implementation

@override
void sortChildrenZIndex() {
  // 根据zIndex排序
  _sortedIdList = [];
  if (_children.length > 1) {
    var sortChildren = <RenderViewModel>[];
    sortChildren.addAll(_children);
    insertionSort<RenderViewModel>(sortChildren, compare: (model1, model2) {
      var index1 = model1.zIndex;
      var index2 = model2.zIndex;
      return index1.compareTo(index2);
    });
    for (var model in sortChildren) {
      _sortedIdList.add(model.id);
    }
  } else if (_children.length == 1) {
    _sortedIdList.add(_children[0].id);
  }
}