update method

void update()

Implementation

void update() {
  LogUtils.dRenderNode(
    "ID:$id, updateStyle start, shouldUpdateView: ${_shouldUpdateView()}",
  );

  if (_shouldUpdateView()) {
    if (_childrenPendingList.isNotEmpty) {
      _childrenPendingList.sort((o1, o2) {
        return o1.indexFromParent.compareTo(o2.indexFromParent);
      });

      for (var i = 0; i < _childrenPendingList.length; i++) {
        var renderNode = _childrenPendingList[i];
        _controllerManager.addChild(this, renderNode, renderNode.indexFromParent);
      }
      _childrenPendingList.clear();
      _notifyManageChildren = true;
    }

    if (_propToUpdate != null) {
      _controllerManager.updateWidget(this, _propToUpdate);
      _propToUpdate = null;
      _hasPropsNeedToApply = true;
    }

    if (_moveHolders.isNotEmpty) {
      for (var moveHolder in _moveHolders) {
        moveHolder._moveRenders.sort((o1, o2) {
          return o1.indexFromParent.compareTo(o2.indexFromParent);
        });

        for (var node in moveHolder._moveRenders) {
          _controllerManager.move(node, moveHolder._moveToNode, node.indexFromParent);
        }
      }
      _moveHolders.clear();
      final idIndexList = this.children.map((e) => e.id).toList();
      /// 元素排序
      _viewModel?.sortChildrenIndex(idIndexList);
    }
    /// 元素ZIndex排序
    _viewModel?.sortChildrenZIndex();


    LogUtils.dRenderNode(
      "ID:$id, update style, update layout start, hasUpdateLayout:$_hasUpdateLayout",
    );
    if (_hasUpdateLayout && !isRoot) {
      _controllerManager.updateLayout(this);
      LogUtils.dRenderNode(
        "ID:$id, update style, update layout end, newLayout:[$layoutX, $layoutY, $_width, $_height]",
      );
      _hasUpdateLayout = false;
    }

    var extraToUpdate = _extraToUpdate;
    if (extraToUpdate != null) {
      _controllerManager.updateExtra(this, extraToUpdate);
      _extraToUpdate = null;
    }

    if (_eventHolders.isNotEmpty) {
      _controllerManager.updateEvents(this, _eventHolders);
      _eventHolders.clear();
    }

    if (_uiFunction.isNotEmpty) {
      for (var i = 0; i < _uiFunction.length; i++) {
        var uiFunction = _uiFunction[i];
        _controllerManager.dispatchUIFunction(
          rootId,
          id,
          name,
          uiFunction._functionName,
          uiFunction._params,
          uiFunction._promise,
        );
      }
      _uiFunction.clear();
    }

    if (_notifyManageChildren) {
      manageChildrenComplete();
      _notifyManageChildren = false;
    }
  }
  LogUtils.dRenderNode("ID:$id, update style end");
}