Pub CommandsSend feedback
Aside from managing packages, pub also has support for building web and command line apps.
If your web app’s directory structure follows pub’s package layout
conventions, you can use the pub
development server (
pub serve) to continuously
build and serve the app’s assets. Once you’re ready to deploy the web app,
pub build to generate the final files.
Quick links to the
Pub’s commands fall into the following categories:
App creation and maintenance
Pub provides a number of commands that support the creation and maintenance of a Dart application.
pub cachecommand works with your system cache. You can add new packages to your cache, or perform a clean reinstall of all packages in your cache.
pub depscommand lists all of the dependencies used by a package.
pub downgradecommand retrieves the lowest versions of all the packages that are listed as dependencies used by the application. This is useful for testing the lower range of your package’s dependencies.
pub getcommand retrieves the packages that are listed as the dependencies for the application.
pub upgradecommand retrieves the latest versions of all the packages that are listed as dependencies used by the application.
Pub supports development for web-based apps and command-line apps.
During the development cycle of an application, the
command is used to start up a development server.
This server can be accessed via the browser on localhost and
allows you to view your web-based app.
IDEs such as WebStorm also use
pub serve to serve all of the
Dart scripts and assets (HTML, images, CSS) to Dartium.
There are two commands that you can use to run Dart scripts from the command line. Each command first runs any needed transformers before invoking the specified script.
pub runcommand invokes a Dart script in your package, or in one of its dependencies.
pub globalcommand lets you work with globally available packages that can be run when you are not currently inside a package.
When you are ready to deploy your app, the
pub build command
build directory, compiles the Dart code, and places
the assets into the build directory.
If you want to share your Dart packages with the world, you can
pub publish command to upload your package to
pub uploader command enables specific users
to modify and upload new versions of your package.
Several command-line options work with all of the pub commands. These include:
- Print usage information.
- Print version of pub.
- Print debugging information when an error occurs.
- The specified level determines the amount of information that is displayed:
- Show all output, including internal tracing messages.
- Show I/O operations.
- Show errors, warnings, and user messages.
- Show steps during version resolution.
- Equivalent to