[Inspector V2] Handle selection of an implementation widget in the app (#8494)
diff --git a/packages/devtools_app/lib/src/screens/inspector_v2/inspector_controller.dart b/packages/devtools_app/lib/src/screens/inspector_v2/inspector_controller.dart index 76aeedf..468154f 100644 --- a/packages/devtools_app/lib/src/screens/inspector_v2/inspector_controller.dart +++ b/packages/devtools_app/lib/src/screens/inspector_v2/inspector_controller.dart
@@ -603,6 +603,25 @@ try { final newSelection = await pendingSelectionFuture; + + // Show an error and don't update the selected node in the tree if the + // user selected an implementation widget in the app while implementation + // widgets are hidden in the tree. + if (implementationWidgetsHidden.value && newSelection != null) { + final isInTree = + valueToInspectorTreeNode.containsKey(newSelection.valueRef); + final hasParent = newSelection.parent != null; + final isImplementationWidget = !isInTree && !hasParent; + if (isImplementationWidget) { + notificationService.pushError( + 'Selected an implementation widget. Please toggle "Show Implementation Widgets" and select a widget from the device again.', + allowDuplicates: true, + isReportable: false, + ); + return; + } + } + if (_disposed || group.disposed) return; selectionGroups.promoteNext(); @@ -650,6 +669,19 @@ _updateSelectedErrorFromNode(_selectedNode.value); unawaited(_loadPropertiesForNode(_selectedNode.value)); + + /// If the user selects a hidden implementation widget, first expand that + /// widget's hideable group before scrolling. + final diagnostic = _selectedNode.value?.diagnostic; + if (diagnostic != null && diagnostic.isHidden) { + inspectorTree.refreshTree( + updateTreeAction: () { + diagnostic.hideableGroupLeader?.toggleHiddenGroup(); + return true; + }, + ); + } + animateTo(selectedNode.value); }
diff --git a/packages/devtools_app/lib/src/shared/notifications.dart b/packages/devtools_app/lib/src/shared/notifications.dart index e613438..943e1b9 100644 --- a/packages/devtools_app/lib/src/shared/notifications.dart +++ b/packages/devtools_app/lib/src/shared/notifications.dart
@@ -71,6 +71,7 @@ String? reportExplanation, bool isDismissible = true, bool isReportable = true, + bool allowDuplicates = false, }) { final reportErrorAction = NotificationAction( label: 'Report error', @@ -105,7 +106,7 @@ ? NotificationMessage.defaultDuration * 2 : NotificationMessage.defaultDuration, ), - allowDuplicates: false, + allowDuplicates: allowDuplicates, ); }
diff --git a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md index b6e2bb9..94ab92b 100644 --- a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md +++ b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
@@ -43,6 +43,7 @@  - Fixed an [issue](https://github.com/flutter/devtools/issues/8487) where the [new Inspector](https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.40.1#inspector-updates) would not load after a hot-restart in the legacy Inspector. - [#8491](https://github.com/flutter/devtools/pull/8491) +- Fixed an [issue](https://github.com/flutter/devtools/issues/8465) preventing scrolling to an implementation widget in the [new Inspector](https://docs.flutter.dev/tools/devtools/release-notes/release-notes-2.40.1#inspector-updates) after selecting it on the device. - [#8494](https://github.com/flutter/devtools/pull/8494) ## Performance updates