Remove bogus code in ContainerParentDataMixin.detach (#37479)
This commit is contained in:
parent
39a04dcd7f
commit
4cf1a3504b
@ -2834,21 +2834,9 @@ mixin ContainerParentDataMixin<ChildType extends RenderObject> on ParentData {
|
||||
/// Clear the sibling pointers.
|
||||
@override
|
||||
void detach() {
|
||||
assert(previousSibling == null, 'Pointers to siblings must be nulled before detaching ParentData.');
|
||||
assert(nextSibling == null, 'Pointers to siblings must be nulled before detaching ParentData.');
|
||||
super.detach();
|
||||
if (previousSibling != null) {
|
||||
final ContainerParentDataMixin<ChildType> previousSiblingParentData = previousSibling.parentData;
|
||||
assert(previousSibling != this);
|
||||
assert(previousSiblingParentData.nextSibling == this);
|
||||
previousSiblingParentData.nextSibling = nextSibling;
|
||||
}
|
||||
if (nextSibling != null) {
|
||||
final ContainerParentDataMixin<ChildType> nextSiblingParentData = nextSibling.parentData;
|
||||
assert(nextSibling != this);
|
||||
assert(nextSiblingParentData.previousSibling == this);
|
||||
nextSiblingParentData.previousSibling = previousSibling;
|
||||
}
|
||||
previousSibling = null;
|
||||
nextSibling = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,27 @@ void main() {
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('ContainerParentDataMixin requires nulled out pointers to siblings before detach', () {
|
||||
expect(() => TestParentData().detach(), isNot(throwsAssertionError));
|
||||
|
||||
final TestParentData data1 = TestParentData()
|
||||
..nextSibling = RenderOpacity()
|
||||
..previousSibling = RenderOpacity();
|
||||
expect(() => data1.detach(), throwsAssertionError);
|
||||
|
||||
final TestParentData data2 = TestParentData()
|
||||
..previousSibling = RenderOpacity();
|
||||
expect(() => data2.detach(), throwsAssertionError);
|
||||
|
||||
final TestParentData data3 = TestParentData()
|
||||
..nextSibling = RenderOpacity();
|
||||
expect(() => data3.detach(), throwsAssertionError);
|
||||
});
|
||||
}
|
||||
|
||||
class TestParentData extends ParentData with ContainerParentDataMixin<RenderBox> { }
|
||||
|
||||
class TestRenderObject extends RenderObject {
|
||||
@override
|
||||
void debugAssertDoesMeetConstraints() { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user