Repository navigation
Don't show an error when selecting an on-device implementation widget - #8625
Conversation
| 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.
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.
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
getSelectionrequest - DevTools uses the response from
getSelectionto 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.
| case FlutterTreeType.widget: | ||
| newSelection = await invokeServiceMethodReturningNodeInspectorRef( | ||
| inLocalProject | ||
| inLocalProjectOnly |
There was a problem hiding this comment.
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.
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.