0 purchases
build version
Include the version of your package in our source code.
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
copied to clipboard
Run a build.
> dart pub run build_runner build
copied to clipboard
lib/src/version.dart will be generated with content:
// Generated code. Do not modify.
const packageVersion = '1.2.3';
copied to clipboard
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
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.