flutter_version_override
A simple CLI tool to override the version field in pubspec.yaml based on environment-specific YAML files β ideal for automating versioning in Flutter projects for multiple environments like development, testing, or production.
π Why use flutter_version_override?
Managing multiple environments often requires different app versions for development, staging, and production. This tool helps you:
- Keep one main
pubspec.yaml. - Maintain separate YAML files containing only the
versionfield, for example:version-development.yamlversion-production.yamlversion-testing.yaml
- Automatically override the
versioninpubspec.yamlwith the version specified in your chosen environment YAML file. - Integrate seamlessly with CI/CD pipelines for automated and consistent versioning across environments.
π¦ Installation
Clone or download this repository, then activate the package globally using Dart:
dart pub global activate flutter_version_override
This will install the executable command fvo globally on your system.
β Usage
-
Prepare your files
-
Your main Flutter projectβs pubspec.yaml.
-
Environment-specific YAML files containing only a version field, for example:
-
Example: version-development.yaml
version: 1.0.5+9
- Run the version override
From the root of your Flutter project, run:
fvo pubspec.yaml version-development.yaml
π§ͺ Example CI/CD Workflow
fvo pubspec.yaml version-${BUILD_ENV}.yaml
flutter pub get
flutter build apk --release
Where ${BUILD_ENV} can be development, production, testing, etc.
π Example Project Structure
my_flutter_project/
βββ pubspec.yaml
βββ versions/
βββ version-development.yaml
βββ version-production.yaml
βββ version-testing.yaml
or
my_flutter_project/
βββ pubspec.yaml
βββ version-development.yaml
βββ version-production.yaml
βββ version-testing.yaml
or any structure u desire
π‘ Tip
If you want to revert your pubspec.yaml to the original version after running fvo, you can use Git:
git restore pubspec.yaml
π License
MIT Β© 2025 Parham Abdollahzadeh
Libraries
- flutter_version_override
- Support for doing something awesome.