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:
- Lookup package details on pub.dev
- Hit the Installing tab and copy the latest version
- Open my pubspec.yaml file in the Dart project
- Add the package and version to
- Save file.
pub getto update my packages
Having programmed in Nodejs I was aware of the npm tool which provided the
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.
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:
To create a new pubspec.yaml file enter
crawl init in your terminal and follow the interactive prompt:
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`
To remove a package run the following command
$ crawl uninstall <package-name>
This package is still early days, but currently you are able to:
- Create a pubspec.yaml file
- Add to
dependenciesincluding specifying a particular version
- Add to
dev_dependenciesincluding specifying a particular version
pub getautomatically to update project dependencies
- Uninstall package
- List unused dependencies in project
- 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
If you enjoyed reading this post, please share this through the various social buttons hovering on the left/top side of the screen . 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 for more content on Dart.