if (!parentUsesSize || sizedByParent || constraints.isTight || parent is! RenderObject) {
relayoutBoundary = this;
} else {
final RenderObject parent = this.parent;
relayoutBoundary = parent._relayoutBoundary;
}
.........
if (_relayoutBoundary != null && relayoutBoundary != _relayoutBoundary) {
// The local relayout boundary has changed, must notify children in case
// they also need updating. Otherwise, they will be confused about what
// their actual relayout boundary is later.
visitChildren((RenderObject child) {
child._cleanRelayoutBoundary();
});
}
_relayoutBoundary = relayoutBoundary;
void markNeedsLayout() {
....
if (_relayoutBoundary != this) {
markParentNeedsLayout();
}
....
}
由以上源码可知,RenderObject中,relayoutBoundary不是自己就是parent。如果是自己,当layout的时候就不会要求parent layout;如果不是自己,当layout的时候就会要求parent layout。
网友评论