[Dart] Update version of pubspec.yaml file by using Bull package

[Dart] Update version of pubspec.yaml file by using Bull package

2023-06-03 hit count image

Let's see how to update the version of the pubspec.yaml file via the command(CLI) by using the Bull package.

Outline

When you develop an app with Flutter, sometimes you need to make a package for the common library or open source and publish it to https://pub.dev/.

At this time, you need to update the version of the pubspec.yaml file. In this blog post, I will introduce how to update the version of the pubspec.yaml file via the command(CLI) by using the Bull package.

Bull package

The Bull package is a package that collects commands that make it easier to develop with Flutter.

This package provides the pub_version command that updates the version of the pubspec.yaml file.

Install Bull package

In order to update the version of the pubspec.yaml file via the command by using the Bull package, let’s install the Bull package. Execute the following command to install the Bull package.

dart pub add --dev bull

In the Flutter package, you can use the following command.

flutter pub add --dev bull

Also, you can open the pubspec.yaml file and add it directly as follows.

...
dev_dependencies:
  bull: [version]
...

If, you want to use the Bull package temporarily, you can activate the Bull package by executing the following commad.

dart pub global activate bull

Update version

After installing the Bull package, you can update the version of the pubspec.yaml file by executing the following command.

dart run bull:pub_version --version build
dart run bull:pub_version --version patch
dart run bull:pub_version --version minor
dart run bull:pub_version --version major
dart run bull:pub_version --version 2.5.7

You can set build, patch, minor, major and specific version to the --version option. If you use the Bull package with global activate, you need to execute the following command.

dart pub global run bull:pub_version --version build
dart pub global run bull:pub_version --version patch
dart pub global run bull:pub_version --version minor
dart pub global run bull:pub_version --version major
dart pub global run bull:pub_version --version 2.5.7

Completed

Done! We’ve see how to update the version of the pubspec.yaml file by executing the command(CLI) of the Bull package. The reason for updating the version of the pubspec.yaml file via the command is to automate when deploying the package to https://pub.dev/. If you are curious about how to deploy a package to pub.dev and automation, please refer to the following link.

The Bull package is a package I made because I needed it. If you want to know how to make a command(CLI) tool in Dart like the Bull package, please refer to the following link.

Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!

App promotion

You can use the applications that are created by this blog writer Deku.
Deku created the applications with Flutter.

If you have interested, please try to download them for free.

Posts