
When building apps for production, you cannot rely on a single environment.
You need to separate development, staging, and production β each with its own Firebase configs, API URLs, and app IDs.
Thatβs where Flavors in Flutter come in.
πΉ Why Flavors are Important?
β
Keep API endpoints separate (dev vs staging vs prod).
β
Manage Firebase projects for each environment.
β
Test safely before shipping to real users.
β
Automate configs β fewer manual mistakes.
β
Professional workflow for production-ready apps.
πΉ Step 1: Add Package
Install flutter_flavorizr (saves tons of manual work):
dev_dependencies:
flutter_flavorizr: ^2.1.4
Run:
flutter pub get
πΉ Step 2: Setup Firebase Configs
Organize Firebase files per environment:
assets/firebase/
βββ development/
β βββ google-services.json
β βββ GoogleService-Info.plist
βββ staging/
β βββ google-services.json
β βββ GoogleService-Info.plist
βββ production/
βββ google-services.json
βββ GoogleService-Info.plist
πΉ Step 3: Add Config JSONs
Inside assets/config/ create environment configs:
π config.development.json
π config.staging.json
π config.production.json
Example:
{
"FLAVOR": "development",
"GOOGLE_AUTH_CLIENT_ID": "1:889331959331:android:cd1780b696d94127fd1396.apps.googleusercontent.com",
"BASE_URL": "https://api-dev.roccovideo.com"
}
πΉ Step 4: Configure flavorizr.yaml
Hereβs a full example π
app:
android:
flavorDimensions: "flavor-type"
flavors:
development:
app:
name: "RB Dev"
android:
applicationId: "dev.rblive.com"
icon: "assets/launcher/launcher_icon.png"
firebase:
config: "assets/firebase/development/google-services.json"
ios:
bundleId: "dev.rblive.com"
icon: "assets/launcher/launcher_icon.png"
firebase:
config: "assets/firebase/development/GoogleService-Info.plist"
staging:
app:
name: "RB Staging"
android:
applicationId: "staging.rblive.com"
icon: "assets/launcher/launcher_icon.png"
firebase:
config: "assets/firebase/staging/google-services.json"
ios:
bundleId: "staging.rblive.com"
icon: "assets/launcher/launcher_icon.png"
firebase:
config: "assets/firebase/staging/GoogleService-Info.plist"
production:
app:
name: "RB Live"
android:
applicationId: "pro.rblive.com"
icon: "assets/launcher/launcher_icon.png"
firebase:
config: "assets/firebase/production/google-services.json"
ios:
bundleId: "prod.rblive.com"
icon: "assets/launcher/launcher_icon.png"
firebase:
config: "assets/firebase/production/GoogleService-Info.plist"
ide: vscode
instructions:
- assets:download
- assets:extract
- android:icons
- android:androidManifest
- android:buildGradle
- ios:xcconfig
- ios:buildTargets
- ios:schema
- ios:icons
- ios:plist
- assets:clean
πΉ Step 5: Generate Flavors
π For Firebase setup:
dart run flutter_flavorizr -p google:firebase
π For flavor configs:
dart run flutter_flavorizr -p android:buildGradle,android:flavorizrGradle,android:androidManifest
πΉ Step 6: Run the App with Flavors
flutter run --flavor development -t lib/main_development.dart
flutter run --flavor staging -t lib/main_staging.dart
flutter run --flavor production -t lib/main_production.dart
π Final Thoughts
With Flutter Flavors, you:
- Keep environments clean π
- Avoid config mixups π«
- Deliver production-grade apps like a pro β
π If youβre serious about publishing apps at scale, Flavors are not optional β theyβre essential.
#Flutter #MobileDevelopment #Firebase #AppDevelopment #FlutterFlavors #ProductionReady