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.


πŸ”§ Command

Use fvo to run this tool from the terminal.

πŸ”₯ Quick Usage

After installing the package, run:

fvo pubspec.yaml override.yaml 

πŸš€ 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 version field, for example:
    • version-development.yaml
    • version-production.yaml
    • version-testing.yaml
  • Automatically override the version in pubspec.yaml with 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

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