For questions relating to the use of and issues with any use of flutter-specific dependencies in dart's pubspec.yaml
Dependencies are one of the core concepts of the pub package manager. A dependency is another package that your package needs in order to work. Dependencies are specified in your pubspec. You list only immediate dependencies — the software that your package uses directly. Pub handles transitive dependencies for you.
For each dependency, you specify the name of the package you depend on and the range of versions of that package that you allow. You can also specify the source, which tells pub how to locate the package, and any additional description that the source needs to find the package.
Here is an example of specifying a dependency:
dependencies:
transmogrify: ^1.0.0
This YAML code creates a dependency on the transmogrify package using the default source (pub.dev) and allowing any version from 1.0.0 to 2.0.0 (but not including 2.0.0). See the version constraints section of this page for syntax details.
If you want to specify a source, the syntax looks a bit different:
dependencies:
transmogrify:
hosted:
name: transmogrify
url: http://some-package-server.com
version: ^1.0.0
This YAML
code creates a dependency on the transmogrify package using the hosted source. Everything under the source key (here, just a map with a url: key) is the description that gets passed to the source. Each source has its own description format, which is described in the dependency sources section of this page. The version constraint is optional but recommended.
Use this long form when you don’t use the default source or when you have a complex description that you need to specify. But in most cases, you’ll just use the simple packagename
: version form.
Pub can use the following sources to locate packages:
SDK
Hosted packages
Git packages
Path packages