Importing packages and dependencies
This recipe shows you how to get packages and plugins from https://pub.dev and integrate them into your app’s pubspec.yaml
file.
Specifically, you will check the version and package name from pub.dev
, import a package into the pubspec.yaml
file in your project, download it, and use it in your classes.
By the end of this recipe, you will know how to import any package available in the pub.dev
hub into your apps.
Getting ready
In this recipe, you will create a new project. There are no prerequisites to follow along.
How to do it...
When you install a package from pub.dev
, the process is very simple. For this example, we will install the http
package and connect to a Git repository:
- Create a new Flutter project, called
plugins
. - Go to https://pub.dev.
- In the search box, type
http
. - Click on the
http
package on the results page. - From the
http
package’s home page, click on the Installing...