-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't show an error when selecting an on-device implementation widget #8625
Don't show an error when selecting an on-device implementation widget #8625
Conversation
@@ -731,37 +732,26 @@ class InspectorController extends DisposableController | |||
final pendingSelectionFuture = group.getSelection( | |||
selectedDiagnostic, | |||
treeType, | |||
// If implementation widgets are hidden, the only widgets in the tree are | |||
// those that were created by the local project. | |||
inLocalProject: implementationWidgetsHidden.value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if implementationWidgetsHidden.value
is false, then the selected widget may or may not be in the local project right? Can we still select a "local project node" if inLocalProject
is false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless of whether implementationWidgetsHidden.value
is true
(only local project widgets in tree) or false
(local project and implementation widgets in tree), the node that the user selected may or may not be in the local project. This is because we allow a user to select any widget with the on-device widget selector. Maybe inLocalProject
is a bad name (I can change it to inLocalProjectOnly
or restrictToLocalProject
?). Because yes we can select a local project node if inLocalProject
is false.
How on-device selection works (I had to poke around a bit because this was unintuitive to me - still want to write up a one-pager at some point):
- a user selects a widget on their device
- the Flutter Widget Inspector sends an "inspect" event
- DevTools intercepts this "inspect" event and sends a
getSelection
request - DevTools uses the response from
getSelection
to determine which node to select in the widget tree
So what this change is doing is modifying the request to getSelection
to ask for the selected local widget (if implementation widgets are hidden in the tree) because we are unable to show the implementation widget in the tree.
@@ -1035,7 +1035,7 @@ class ObjectGroup extends InspectorObjectGroupBase { | |||
switch (treeType) { | |||
case FlutterTreeType.widget: | |||
newSelection = await invokeServiceMethodReturningNodeInspectorRef( | |||
inLocalProject | |||
inLocalProjectOnly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like the 'restrictToLocalProject' name that you suggested. I think this makes it more clear that the response is going to be restricted to a specific set of widgets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SG! Switch to restrictToLocalProject
Work towards #8626
In #8494, we added an error notification when a user selects an implementation widget on their device, but implementation widgets are hidden. This is not the most friendly UI.
Instead, with this PR we select the implementation widget's ancestor in the tree, and show a notification (not an error) that an implementation widget has been selected.