Merge pull request #349 from abarth/reparent_data
Parent data not updated when reparenting using global keys
This commit is contained in:
@@ -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),
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user