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
Support URLs and paths in Add Dependency command #3635
I am using v3.27.2 of the extension and I searched for a similar issue but I didn't find anything related.
Currently, the auto-completion about dependencies just works in pubspec.yaml but I think it can be better to add the dependencies in import (for tired guys can be the best solution).
At this time the process for using a package is: (expect its kind - local, hosted on pub server or as a dev dep)
Adding dependencies in pubspec.yaml
Runnin pub get to fetch the package and other related configs
import it and use it
But I suggest a new way (I am not sure this feature can be implemented in extension or not let me know).
For example, we want to add a dependency in the dependency section in pubspec.yaml what we should do is:
import the package with this syntax import 'dep:<package_name | git_remote_repo | local/path/to/package>'; auto completion works as same logic as used in pubspec.yaml (with some modification)
crtl + . click on fetch package
then pub add <package_name> --<associated_switch> will run and do all configurations
Note: as dev dependency we can use import 'dev:<package_name | git_remote_repo | local/path/to/package>';
It wouldn't be technically difficult to include the packages in package:foo/ in the import completion - however, I think it would be odd to complete on the first part and then not be able to complete on the filename part (eg. /foo.dart).
We do have a quick fix for adding the dependency automatically if you paste in the import though, eg.:
It's not exactly what was requested, but perhaps it works as an alternative?
Yeah as you said it works as an alternative and it isn't what exactly I want.
I think auto-completion and special syntax can be better because users can see what they want as same as in pubspec.yaml
This is what I want and what is added to the extension.
and after that, we do the process as same as past (ctrl + . then click add to dependencies)
auto-completion can work for both path and regular one (fetching from pub server). I think can be implemented for GitHub I am not sure about GitHub REST API limitations.
I'm not sure if I entirely understand the suggestion. Are you expecting to type the dev: string, or for it to be in code completion? I'm not sure it makes sense to put invalid code into the code completion, and I'm also unsure of the benefit of typing it yourself as there are existing commands for adding dependencies, see https://dartcode.org/releases/v3-25/#improved-dependency-management
Perhaps extending the Add Dependency commands to accept URLs and paths (in addition to the existing list of pub package names) would address the request?
I think I should have reviewed the feature before suggesting it. Actually, I agree with you about extending Add Dependency to accept URLs and paths, it would be a better solution 👍🏾
The way I was thinking it would work is that we insert two new items in the picklist, one for URLs and one for paths. Select the path option would open the folder picker and let you browser to the folder, and picking URL would just give an input box that is validated as a URL. Then the results just get passed to pub add the same way the package name would.
Thank you a lot for your response I will try to implement it on my forked repository based on contribution guidlines. I just wanted to aware you to avoid conflict.
@EhsanAramide it's not problem at all, I understand how things are. I'll work on this for the next release - thank you for your effort in starting this though! :-)
Activity
DanTup commentedon Oct 26, 2021
It wouldn't be technically difficult to include the packages in
package:foo/in the import completion - however, I think it would be odd to complete on the first part and then not be able to complete on the filename part (eg./foo.dart).We do have a quick fix for adding the dependency automatically if you paste in the import though, eg.:
It's not exactly what was requested, but perhaps it works as an alternative?
EhsanAramide commentedon Oct 26, 2021
Yeah as you said it works as an alternative and it isn't what exactly I want.
I think auto-completion and special syntax can be better because users can see what they want as same as in pubspec.yaml
EhsanAramide commentedon Oct 26, 2021
This is what I want and what is added to the extension.
and after that, we do the process as same as past (
ctrl + .then click add to dependencies)auto-completion can work for both path and regular one (fetching from pub server). I think can be implemented for GitHub I am not sure about GitHub REST API limitations.
and this is for dev dependencies.

DanTup commentedon Oct 27, 2021
I'm not sure if I entirely understand the suggestion. Are you expecting to type the
dev:string, or for it to be in code completion? I'm not sure it makes sense to put invalid code into the code completion, and I'm also unsure of the benefit of typing it yourself as there are existing commands for adding dependencies, see https://dartcode.org/releases/v3-25/#improved-dependency-managementPerhaps extending the Add Dependency commands to accept URLs and paths (in addition to the existing list of pub package names) would address the request?
EhsanAramide commentedon Oct 29, 2021
I think I should have reviewed the feature before suggesting it. Actually, I agree with you about extending Add Dependency to accept URLs and paths, it would be a better solution 👍🏾
DanTup commentedon Nov 1, 2021
sgtm, I'll do that. Thanks!
[-]importing dependencies and auto-completion [/-][+]Support URLs and paths in Add Dependency command[/+]EhsanAramide commentedon Nov 1, 2021
Me too. You can count on me in feature implementation (I am not a TS expert but I can do some stuff with it😅🌹)
DanTup commentedon Nov 1, 2021
You're welcome to have a go if you want :-)
The way I was thinking it would work is that we insert two new items in the picklist, one for URLs and one for paths. Select the path option would open the folder picker and let you browser to the folder, and picking URL would just give an input box that is validated as a URL. Then the results just get passed to
pub addthe same way the package name would.EhsanAramide commentedon Nov 1, 2021
Thank you a lot for your response I will try to implement it on my forked repository based on contribution guidlines. I just wanted to aware you to avoid conflict.
DanTup commentedon Nov 22, 2021
@EhsanAramide are you still working on this? There's no rush, but if you don't have time I'm happy to try to finish it off for the upcoming release.
EhsanAramide commentedon Nov 22, 2021
Thank you to make me notify, Yes as you said unfortunately I don't have time these days, I am sorry about it.💙🌹🌹
DanTup commentedon Nov 22, 2021
@EhsanAramide it's not problem at all, I understand how things are. I'll work on this for the next release - thank you for your effort in starting this though! :-)
Tweak Add Dependency to include package names in initial list