Commit b628ff40 authored by Adam Barth's avatar Adam Barth

Merge pull request #349 from abarth/reparent_data

Parent data not updated when reparenting using global keys
parents f0825a82 35464f44
......@@ -1275,9 +1275,6 @@ abstract class RenderObjectElement<T extends RenderObjectWidget> extends Buildab
super.mount(parent, newSlot);
assert(_slot == newSlot);
attachRenderObject(newSlot);
ParentDataElement parentDataElement = _findAncestorParentDataElement();
if (parentDataElement != null)
updateParentData(parentDataElement.widget);
_dirty = false;
}
......@@ -1491,6 +1488,9 @@ abstract class RenderObjectElement<T extends RenderObjectWidget> extends Buildab
_slot = newSlot;
_ancestorRenderObjectElement = _findAncestorRenderObjectElement();
_ancestorRenderObjectElement?.insertChildRenderObject(renderObject, newSlot);
ParentDataElement parentDataElement = _findAncestorParentDataElement();
if (parentDataElement != null)
updateParentData(parentDataElement.widget);
}
void detachRenderObject() {
......
......@@ -284,4 +284,55 @@ void main() {
checkTree(tester, <TestParentData>[]);
});
});
test('ParentDataWidget interacts with global keys', () {
testWidgets((WidgetTester tester) {
GlobalKey key = new GlobalKey();
tester.pumpWidget(
new Stack(<Widget>[
new Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(key: key, decoration: kBoxDecorationA)
)
])
);
checkTree(tester, <TestParentData>[
new TestParentData(top: 10.0, left: 10.0),
]);
tester.pumpWidget(
new Stack(<Widget>[
new Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(
decoration: kBoxDecorationB,
child: new DecoratedBox(key: key, decoration: kBoxDecorationA)
)
)
])
);
checkTree(tester, <TestParentData>[
new TestParentData(top: 10.0, left: 10.0),
]);
tester.pumpWidget(
new Stack(<Widget>[
new Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(key: key, decoration: kBoxDecorationA)
)
])
);
checkTree(tester, <TestParentData>[
new TestParentData(top: 10.0, left: 10.0),
]);
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment