Unverified Commit 0cc58fd0 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Fix assert in RenderObject.getTransformTo() (#81590)

The assert was never hitting because it was first hitting a
null cast error in the `renderer.parent!` line in the for
loop.
parent 9956a35a
......@@ -2397,8 +2397,8 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
}
final List<RenderObject> renderers = <RenderObject>[];
for (RenderObject renderer = this; renderer != ancestor; renderer = renderer.parent! as RenderObject) {
assert(renderer != null); // Failed to find ancestor in parent chain.
renderers.add(renderer);
assert(renderer.parent != null); // Failed to find ancestor in parent chain.
}
if (ancestorSpecified)
renderers.add(ancestor!);
......
......@@ -100,6 +100,15 @@ void main() {
expect(() => data3.detach(), throwsAssertionError);
});
test('RenderObject.getTransformTo asserts is argument is not descendant', () {
final PipelineOwner owner = PipelineOwner();
final TestRenderObject renderObject1 = TestRenderObject();
renderObject1.attach(owner);
final TestRenderObject renderObject2 = TestRenderObject();
renderObject2.attach(owner);
expect(() => renderObject1.getTransformTo(renderObject2), throwsAssertionError);
});
test('PaintingContext.pushClipRect reuses the layer', () {
_testPaintingContextLayerReuse<ClipRectLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushClipRect(true, offset, Rect.zero, painter, oldLayer: oldLayer as ClipRectLayer?);
......
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