Search packages, repositories and app categories

Package detailsv2.2.1

build_version

A builder for extracting a package version into code.

AndroidiOSmacOSWindowsLinux
30-day downloads
129K
Likes
34
Pub points
150

Install package

flutter pub add build_version

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

build_version is a Flutter/Dart package that generates a Dart file containing the current version of a package during the build process. It extracts version information from pubspec.yaml and makes it available as a constant in the application code, enabling runtime access to version details without manual updates. This is particularly useful for debugging, logging, or displaying version numbers in the UI. The package integrates seamlessly with the build_runner and supports multiple platforms including Android, iOS, macOS, Windows, and Linux.

Use cases

  • Displaying app version in settings
  • Logging version info for debugging
  • Automating version injection into code
  • Tracking release versions in builds
  • Enabling version checks in app logic

Key features

  • Auto-generates version constants
  • Extracts version from pubspec.yaml
  • Supports multiple platforms
  • Integrates with build_runner
  • Minimal configuration required

Suitable for

  • Apps needing runtime version access
  • Teams wanting automated version management
  • Projects using build_runner workflows
  • Developers seeking minimal boilerplate
  • CI/CD pipelines requiring version metadata

Considerations

  • Requires build_runner to be set up
  • Version is static after build
  • Not suitable for dynamic version changes
  • May require rebuild on version update
  • Limited to version field in pubspec.yaml

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

CI Pub Package package publisher

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 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 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

Categories

Dependencies

Dependency list 4 items

Source repository

Projects using this package