You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Automatically selecting a project to add a dependency to from the open file is not obvious, should instead show a pick-list with it pre-selected #5502
Describe the bug
I have a packages folder with some flutter and dart packages. When I try to add a new dependency I can't select where I want to add this dependency (see example on the attached screenshot).
Expected behavior
To have a choice where I can add a new dependency as on the screenshot
Screenshots
Please complete the following information:
You can run the Dart: Collect Diagnostic Information command from the VS Code command palette (F1) to easily capture this information or provide it manually.
macOS 13.5.1
VS Code version: 1.99.3
Dart extension version: 3.110.0
Dart/Flutter SDK version: 3.7.2/3.29.3
Target device (if the issue relates to Flutter debugging): -
@dhutaryan I'm not sure I understand - isn't the screenshot showing that you can select a location?
Or is this not your screenshot?
Assuming not, can you confirm how you're adding the dependency - are you invoking the "Add Dependency" command from the palette? What happens when you invoke it?
One thing to note that may or may not be related, is that the "Add Dependency" command will automatically select the project of the active file if there is one. It assumes (possibly incorrectly) that you want to add the dependency to the package for the file you're working in.
@dhutaryan I'm not sure I understand - isn't the screenshot showing that you can select a location?
Or is this not your screenshot?
screenshot is expected result
Assuming not, can you confirm how you're adding the dependency - are you invoking the "Add Dependency" command from the palette? What happens when you invoke it?
yes, from the palette. I can add dependency in the root project only. Extension doesn't provide me to select the package.
Interesting thing. Everything has worked as expected after I initialized git for the project.
I wonder if we should change this so instead of asking for a single project, we show a checkbox-list for all projects, and just pre-tick the current project (and ofc if there is only one project, we can skip the prompt). That way you only have to press <enter> once more to get the current behaviour, but you can also easily add it to multiple (or different) projects fairly easy?
changed the title [-]There are no choice to select a package when install a new dependency[/-][+]Automatically selecting a project to add a dependency to from the open file is not obvious, should instead show a pick-list with it pre-selected[/+]on May 27, 2025
Now if there is more than one project, we'll always show the project selector with the project for the active file pre-selected. You can just hit <enter> to accept this (which gives the same behaviour as before), or you can change which package it gets added to.
Activity
DanTup commentedon May 6, 2025
@dhutaryan I'm not sure I understand - isn't the screenshot showing that you can select a location?
Or is this not your screenshot?
Assuming not, can you confirm how you're adding the dependency - are you invoking the "Add Dependency" command from the palette? What happens when you invoke it?
DanTup commentedon May 6, 2025
One thing to note that may or may not be related, is that the "Add Dependency" command will automatically select the project of the active file if there is one. It assumes (possibly incorrectly) that you want to add the dependency to the package for the file you're working in.
dhutaryan commentedon May 6, 2025
screenshot is expected result
yes, from the palette. I can add dependency in the root project only. Extension doesn't provide me to select the package.
Interesting thing. Everything has worked as expected after I initialized git for the project.
DanTup commentedon May 6, 2025
@dhutaryan could it be what I mentioned above - that it automatically selected the project for the current active/open file?
dhutaryan commentedon May 6, 2025
Seems yes. It automatically selects the project for which the file is opened.
DanTup commentedon May 6, 2025
I wonder if we should change this so instead of asking for a single project, we show a checkbox-list for all projects, and just pre-tick the current project (and ofc if there is only one project, we can skip the prompt). That way you only have to press
<enter>once more to get the current behaviour, but you can also easily add it to multiple (or different) projects fairly easy?dhutaryan commentedon May 7, 2025
I have no idea :) I thought it didn't work at all. Probably, your option makes sense.
[-]There are no choice to select a package when install a new dependency[/-][+]Automatically selecting a project to add a dependency to from the open file is not obvious, should instead show a pick-list with it pre-selected[/+]DanTup commentedon Jun 9, 2025
Now if there is more than one project, we'll always show the project selector with the project for the active file pre-selected. You can just hit
<enter>to accept this (which gives the same behaviour as before), or you can change which package it gets added to.Support multiple projects for "Add Dependency" command