Unverified Commit 96903947 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Update objectToDiagnosticsNode to stop failing. (#129027)

Prerequisite for https://github.com/flutter/devtools/pull/5918
parent 3f73d2c4
...@@ -1764,17 +1764,20 @@ mixin WidgetInspectorService { ...@@ -1764,17 +1764,20 @@ mixin WidgetInspectorService {
// TODO(polina-c): start always assuming Diagnosticable, when DevTools stops sending DiagnosticsNode to // TODO(polina-c): start always assuming Diagnosticable, when DevTools stops sending DiagnosticsNode to
// APIs that invoke this method. // APIs that invoke this method.
// https://github.com/flutter/devtools/issues/3951 // https://github.com/flutter/devtools/issues/3951
final Object? theObject = toObject(diagnosticsOrDiagnosticableId); final Object? object = toObject(diagnosticsOrDiagnosticableId);
if (theObject is DiagnosticsNode) { return objectToDiagnosticsNode(object);
return theObject; }
}
if (theObject is Diagnosticable) { /// If posiible, returns [DiagnosticsNode] for the object.
return theObject.toDiagnosticsNode(); @visibleForTesting
static DiagnosticsNode? objectToDiagnosticsNode(Object? object) {
if (object is DiagnosticsNode) {
return object;
} }
if (theObject == null) { if (object is Diagnosticable) {
return null; return object.toDiagnosticsNode();
} }
throw StateError('Unexpected object type ${theObject.runtimeType}.'); return null;
} }
List<Object> _getChildrenSummaryTree(String? diagnosticsOrDiagnosticableId, String groupName) { List<Object> _getChildrenSummaryTree(String? diagnosticsOrDiagnosticableId, String groupName) {
......
...@@ -261,6 +261,10 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { ...@@ -261,6 +261,10 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
} }
}); });
test ('objectToDiagnosticsNode returns null for non-diagnosticable', () {
expect(WidgetInspectorService.objectToDiagnosticsNode(Alignment.bottomCenter), isNull);
});
testWidgets('WidgetInspector smoke test', (WidgetTester tester) async { testWidgets('WidgetInspector smoke test', (WidgetTester tester) async {
// This is a smoke test to verify that adding the inspector doesn't crash. // This is a smoke test to verify that adding the inspector doesn't crash.
await tester.pumpWidget( await tester.pumpWidget(
......
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