Creative Bracket

Manage Dart packages with Crawl

Crawl logo

Although we’ve got tools like Stagehand to generate the boilerplate for a Dart project, a pain-point I’ve experienced regularly is managing Dart packages. Whenever I needed to add a new package, I usually followed the steps below:

  1. Lookup package details on pub.dev
  2. Hit the Installing tab and copy the latest version
  3. Open my pubspec.yaml file in the Dart project
  4. Add the package and version to dependencies or dev_dependencies list
  5. Save file.
  6. Run pub get to update my packages

Having programmed in Nodejs I was aware of the npm tool which provided the init and install commands to automate the creation and maintenance of packages.

After searching around I came across the Pubspec Assist extension for VS Code that enabled me to search and install a package through the UI. It works in most cases but I wasn’t content that I had to be in the editor in order to use it! So instead of complaining I decided I’ll write my own.

Introducing Crawl

Crawl helps you manage Dart packages in your pubspec.yaml files. It borrows inspiration from the npm tool and will be familiar if you have used it.

The only pre-requisite is the Dart runtime and you can install Crawl by running pub global activate crawl. This will enable the crawl executable in your terminal.

To launch the usage screen simply run crawl in your terminal:

Listing Crawl usage commands

To create a new pubspec.yaml file enter crawl init in your terminal and follow the interactive prompt:

Launching Crawl interactive prompt for creating pubspec.yaml file

To add a new package run the following command:

$ crawl install -p <package-name> # eg: `crawl install -p shelf`
$ crawl install -p <package-name> -v <version> # eg: `crawl install -p shelf -v 0.7.9`
Installing shelf package with Crawl

To remove a package run the following command

$ crawl uninstall <package-name>

This package is still early days, but currently you are able to:

  1. Create a pubspec.yaml file
  2. Add to dependencies including specifying a particular version
  3. Add to dev_dependencies including specifying a particular version
  4. Run pub get automatically to update project dependencies
  5. Uninstall package
  6. List unused dependencies in project
  7. Lookup package information on Pub repository

Try it out and let me know what you think 😊 Although the Dart team will be introducing a pub add and pub remove command in the next release, this tool provides other commands that will be useful in your projects.


Sharing is caring smile emoji

If you enjoyed reading this post, please share this through the various social buttons hovering on the left/top side of the screen ↖️arrow up emoji. Also, check out and subscribe to my YouTube channel (hit the bell icon too) for videos on Dart.

Subscribe to the newsletter for my free 35-page Get started with Dart eBook and to be notified when new content is released.

Like, share and follow me heart eyes emoji for more content on Dart.

Jermaine Oppong

Hello 👋, I show programmers how to build full-stack web applications with the Dart SDK. I am passionate about teaching others, having received tremendous support on sites like dev.to and medium.com for my articles covering various aspects of the Dart language and ecosystem.

Useful learning materials