build_version 2.1.1 icon indicating copy to clipboard operation
build_version: ^2.1.1 copied to clipboard

A builder for extracting a package version into code.

Pub

Include the version of your package in our source code.

  1. Add build_version to pubspec.yaml. Also make sure there is a version field.

     name: my_pkg
     version: 1.2.3
     dev_dependencies:
       build_runner: ^1.0.0
       build_version: ^2.0.0
    
  2. Run a build.

     > dart pub run build_runner build
    

    lib/src/version.dart will be generated with content:

     // Generated code. Do not modify.
     const packageVersion = '1.2.3';
    

To change the path of the generated file, create a [build.yaml](build config) in the root of your package. By changing the output option of this builder, the path can be customized:

targets:
  $default:
    builders:
      build_version:
        options:
          output: lib/src/custom/path/to/version.dart
14
likes
110
pub points
91%
popularity

Publisher

verified publisher iconj832.com

A builder for extracting a package version into code.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.BSD-3-Clause (LICENSE)

Dependencies

build, build_config, pubspec_parse

More

Packages that depend on build_version