mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #1941 from abarth/stale_parent_data
Always reset parentData when dropping children
This commit is contained in:
commit
40e0586802
@ -464,6 +464,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
|
||||
assert(child.parentData != null);
|
||||
child._cleanRelayoutSubtreeRoot();
|
||||
child.parentData.detach();
|
||||
child.parentData = null;
|
||||
super.dropChild(child);
|
||||
markNeedsLayout();
|
||||
_markNeedsCompositingBitsUpdate();
|
||||
|
||||
@ -73,4 +73,25 @@ void main() {
|
||||
expect(coloredBox.size.width, equals(780.0));
|
||||
expect(coloredBox.size.height, equals(580.0));
|
||||
});
|
||||
|
||||
test("reparenting should clear position", () {
|
||||
RenderDecoratedBox coloredBox = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration());
|
||||
RenderPadding paddedBox = new RenderPadding(
|
||||
child: coloredBox, padding: const EdgeDims.all(10.0));
|
||||
|
||||
layout(paddedBox);
|
||||
|
||||
BoxParentData parentData = coloredBox.parentData;
|
||||
expect(parentData.position.x, isNot(equals(0.0)));
|
||||
|
||||
paddedBox.child = null;
|
||||
RenderConstrainedBox constraintedBox = new RenderConstrainedBox(
|
||||
child: coloredBox, additionalConstraints: const BoxConstraints());
|
||||
|
||||
layout(constraintedBox);
|
||||
|
||||
parentData = coloredBox.parentData;
|
||||
expect(parentData.position.x, equals(0.0));
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user