The Dart code generator for your package versions.
There is no way to get the package version from the code in the Dart ecosystem.

Installation

  1. Add build_runner and VersionGen to your package’s pubspec.yaml file:

dev_dependencies:
  build_runner:
  version_gen:
  1. Install VersionGen

$ flutter pub get
  1. Use VersionGen

$ flutter packages pub run build_runner build

Configuration file

VersionGen generates dart files based on the key VersionGen of pubspec.yaml.
Default configuration can be found here.

# pubspec.yaml
# ...

dev_dependencies:
  build_runner:
  version_gen:

# Optional (default: lib/gen/)
version_gen:
  path: lib/gen/

Output file

/// DO NOT MODIFY BY HAND, Generated by version_gen
String packageVersion = '1.0.0+1';

Issues

Please file [FlutterGen] specific issues, bugs, or feature requests in our issue tracker.

Plugin issues that are not specific to [FlutterGen] can be filed in the Flutter issue tracker.

GitHub

View Github