September 2019
Beginner
512 pages
12h 52m
English
Now that you know how the pub tool resolves packages inside the project, let's take a look at how to add dependencies to it.
Dependencies are specified in the dependencies field of the pubspec file. It is a YAML list field, so you can specify as many as needed in the field. Let's suppose that we need the json_serializable package in our project. We can specify it by simply adding to the list, as follows:
name: adding_dependenciesdependencies: json_serializable: # another packages below
The syntax to specify a dependency is as follows:
<package>: <constraints>
Here, you add its name (<package>) followed by the <constraints> fields: version and source. In this case, we did not specify any constraint, so it assumes any ...
Read now
Unlock full access