renderObject property Null safety
The render object at (or below) this location in the tree.
If this object is a RenderObjectElement, the render object is the one at this location in the tree. Otherwise, this getter will walk down the tree until it finds a RenderObjectElement.
Implementation
RenderObject? get renderObject {
RenderObject? result;
void visit(Element element) {
assert(result == null); // this verifies that there's only one child
if (element._lifecycleState == _ElementLifecycle.defunct) {
return;
} else if (element is RenderObjectElement) {
result = element.renderObject;
} else {
element.visitChildren(visit);
}
}
visit(this);
return result;
}