Unverified Commit c243d834 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Fix _LateInitializationError for RenderObjectElement.renderObject (#70974)

parent 5bc725be
......@@ -5463,8 +5463,8 @@ abstract class RenderObjectElement extends Element {
/// The underlying [RenderObject] for this element.
@override
RenderObject get renderObject => _renderObject;
late RenderObject _renderObject;
RenderObject get renderObject => _renderObject!;
RenderObject? _renderObject;
bool _debugDoingBuild = false;
@override
......@@ -5566,7 +5566,7 @@ abstract class RenderObjectElement extends Element {
void _debugUpdateRenderObjectOwner() {
assert(() {
_renderObject.debugCreator = DebugCreator(this);
renderObject.debugCreator = DebugCreator(this);
return true;
}());
}
......@@ -6058,7 +6058,7 @@ abstract class RenderObjectElement extends Element {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<RenderObject>('renderObject', renderObject, defaultValue: null));
properties.add(DiagnosticsProperty<RenderObject>('renderObject', _renderObject, defaultValue: null));
}
}
......
......@@ -1494,6 +1494,12 @@ void main() {
expect(GestureBinding.instance!.pointerRouter.debugGlobalRouteCount, pointerRouterCount);
expect(RawKeyboard.instance.keyEventHandler, same(rawKeyEventHandler));
});
testWidgets('Can access debugFillProperties without _LateInitializationError', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
TestRenderObjectElement().debugFillProperties(builder);
expect(builder.properties.any((DiagnosticsNode property) => property.name == 'renderObject' && property.value == null), isTrue);
});
}
class _FakeFocusManager implements FocusManager {
......@@ -1837,3 +1843,7 @@ class FakeLeafRenderObject extends RenderBox {
size = constraints.biggest;
}
}
class TestRenderObjectElement extends RenderObjectElement {
TestRenderObjectElement() : super(Table());
}
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