A modern CLI tool for managing flavor-based environment configurations in Flutter projects
A CLI tool to generate and manage flavor-based environment variable files for Flutter projects. Simplify environment configuration across different build flavors (development, staging, production) with schema validation and automated code generation.
- π¦ Flavor Management β Create, remove, and list environment flavors with ease
- π Schema-Based Variables β Define environment variables in a centralized schema file
- π Environment Operations β Add, remove, set, and manage variables per flavor
- β Sync & Validate β Keep all flavors consistent and validate configurations
- π§ββοΈ Interactive Wizard β Step-by-step guided setup for fast onboarding
- π» Developer-Friendly β Intuitive CLI with helpful error messages
- π Code Generation β Generate type-safe Dart code from configuration files using
envied
- Features
- Getting Started
- Installation
- Usage
- Example Workflows
- Project Structure
- Security
- Contributing
- Issues & Support
- License
- Dart SDK
3.4.0or higher
To enable code generation features, add these to your pubspec.yaml:
dependencies:
envied: ^1.3.4
dev_dependencies:
build_runner: ^2.13.1
envied_generator: ^1.3.4Then install:
flutter pub get
# or
dart pub getNote: The envied package provides:
- π Type-safe access with compile-time verification
- π Configuration management for different flavors
- π Keeps
.envout of source control if properly gitignored
dart pub global activate envflare_cliVerify installation:
envflare --helpFor a guided, interactive setup experience:
envflare wizardThis launches an interactive menu where you can:
| Option | Description |
|---|---|
| Initialize project with flavors and keys | Set up your project from scratch with flavors and environment variables |
| Add a new flavor | Add a new flavor (e.g., staging, prod) to your configuration |
| Add a new environment variable key | Add a new environment variable to all flavors |
| Remove an environment variable key | Remove an environment variable from all flavors |
envflare wizard
β Select: "Initialize project with flavors and keys"Guides you through creating and configuring your .env.schema and .envflare_cli.json.
envflare wizard
β Select: "Add a new flavor"Add a new flavor and set values for all existing environment keys.
envflare wizard
β Select: "Add a new environment variable key"Add a new variable to the schema and set values for all flavors.
envflare wizard
β Select: "Remove an environment variable key"Remove a variable from all flavors and the schema.
For more control, use individual commands:
envflare initCreates .env.schema and .envflare_cli.json in your project root.
# Add a new flavor
envflare flavor add development
# List all flavors
envflare flavor list
# Remove a flavor
envflare flavor remove development# Add a variable to schema and all flavors
envflare add API_URL
# Set a variable for specific flavor
envflare set API_URL https://dev.api.com --flavor development
# Set a variable for all flavors
envflare set DEBUG true
# List variables for a flavor
envflare list --flavor development
# List all variables across flavors
envflare list
# Remove a variable from all flavors
envflare remove API_URL# Sync variables across flavors (add missing ones)
envflare sync
# Validate all configurations
envflare validate# Generate Dart code from .env files
envflare generateCreates environment classes using the envied package for secure variable access. See Security section for details on how envied protects your environment variables.
# Start the wizard
envflare wizard
# Follow the prompts to:
# 1. Initialize project
# 2. Add flavors (dev, staging, prod)
# 3. Add environment variables (API_URL, DEBUG_MODE, etc.)
# 4. Set values for each flavor
# 5. Generate code# 1. Initialize
envflare init
# 2. Add flavors
envflare flavor add dev
envflare flavor add prod
# 3. Add variables
envflare add API_BASE_URL
envflare add DEBUG_MODE
# 4. Set values
envflare set API_BASE_URL https://dev.api.com --flavor dev
envflare set API_BASE_URL https://prod.api.com --flavor prod
envflare set DEBUG_MODE true --flavor dev
envflare set DEBUG_MODE false --flavor prod
# 5. Generate code
envflare generateAfter initialization, your project will have the following structure:
project-root/
βββ .env.schema # Schema defining all environment variables
βββ .envflare_cli.json # Configuration file with flavor list
βββ .envs/
βββ dev.env # Development environment variables
βββ staging.env # Staging environment variables
βββ prod.env # Production environment variables
| File | Purpose |
|---|---|
.env.schema |
Defines all available environment variable keys |
.envflare_cli.json |
Stores flavor list and project configuration |
.envs/*.env |
Contains environment variables for each flavor (local only, never commit to version control) |
envflare_cli integrates with envied to improve configuration management and provide basic protection for environment values during development.
- Type-safe access β Compile-time verification of environment variables
- Keeps
.envfiles out of source control β Prevents accidental commits via.gitignore - Configuration per flavor β Manage different values for development, staging, production
- Code obfuscation β Makes static extraction of values harder
- Reduces accidental plaintext secrets β Keeps configuration out of source files
- Non-sensitive configuration management β API base URLs, feature flags, app identifiers
envied is NOT a secret vault.
Understand these limitations:
- Values may still be compiled into your binary β Code obfuscation makes extraction harder, but not impossible
- Code generation happens at build time β Values are read from
.envduringbuild_runnerexecution and embedded in generated code - Determined attackers can recover values β With reverse engineering tools and effort, strings may be extractable
- Not suitable for high-security secrets β Use this only for non-sensitive configuration
The generated code from envflare generate:
- Reads
.envfiles at build time - Generates Dart source code with environment values
- Applies code obfuscation to make extraction harder
- Provides type-safe accessors for your configuration
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Found a bug? Report it on GitHub
- Have a feature request? Create an issue
- Questions? Feel free to open a discussion
This project is licensed under the MIT License β see the LICENSE file for details.
Created with β€οΈ by Muhammad Rizky
Made to simplify Flutter environment management