Sooner or later you test against production by accident: a fake purchase in the real database, a test push to every user, analytics full of your own taps. Flavors fix that. You get two apps from one codebase, a dev build and a prod build, installed side by side with different names, bundle IDs and Firebase projects.
This post sets up dev and prod flavors on Android and iOS and wires each to its own Firebase project. It follows Flutter’s official flavor guides and fits into building a Flutter app with Claude Code.
What a flavor changes
For each flavor you will set:
- Application ID / bundle ID:
com.example.app.devandcom.example.app. Different IDs let both install at once. - Display name: “App Dev” and “App”.
- Firebase project:
myapp-devandmyapp-prod. - Optionally an icon and splash so you can tell them apart at a glance.
Firebase’s guidance on the last point is direct: “Firebase recommends using a separate Firebase project for each environment in your development workflow.”
Android: product flavors
In android/app/build.gradle.kts, inside android { }:
flavorDimensions += "default"
productFlavors {
create("dev") {
dimension = "default"
applicationIdSuffix = ".dev"
}
create("prod") {
dimension = "default"
}
}
Flutter’s example uses a suffix on both flavors. Leaving prod without a suffix keeps your store package name unchanged, which matters because Google says “Package names can’t be deleted or re-used.”
For the app name, create one strings.xml per flavor:
<!-- android/app/src/dev/res/values/strings.xml -->
<resources>
<string name="app_name">App Dev</string>
</resources>
Repeat in android/app/src/prod/res/values/ with the real name, and use @string/app_name as android:label in the manifest. Flutter’s docs warn against the older resValue() approach: with Android Gradle Plugin 9.0 or later those builds “fail by default” with a “custom resource values” error.
iOS: schemes and build configurations
iOS has no product flavors. Flutter maps a flavor to an Xcode scheme plus build configurations. Open ios/Runner.xcworkspace and:
- Create schemes. Product > Scheme > New Scheme, target Runner, name
dev. Repeat forprod. In Manage Schemes, make sure Shared is checked. - Duplicate build configurations. In the project’s Info tab, duplicate Debug as
Debug-devandDebug-prod, then do the same for Release and Profile. Flutter says to “always use lowercase for the appended flavor name” so the CLI recognizes it. - Assign configurations to each scheme. For
dev: Run, Test and Analyze useDebug-dev, Profile usesProfile-dev, Archive usesRelease-dev. Same pattern forprod. - Set bundle IDs. Runner target > Build Settings > Product Bundle Identifier, per configuration:
com.example.app.devfor the dev ones,com.example.appfor the rest. Register each ID in your Apple Developer account. - Set display names. Add a user-defined build setting
APP_DISPLAY_NAMEwith a value per configuration, and setCFBundleDisplayNameinInfo.plistto$(APP_DISPLAY_NAME). - Update the Podfile if you have one, so CocoaPods knows the new configurations:
project 'Runner', {
'Debug' => :debug,
'Debug-dev' => :debug,
'Debug-prod' => :debug,
'Profile' => :release,
'Profile-dev' => :release,
'Profile-prod' => :release,
'Release' => :release,
'Release-dev' => :release,
'Release-prod' => :release,
}
Two easy mistakes here: a scheme that is not marked Shared, and a configuration name with a capital letter in the flavor part.
Run and build
flutter run --flavor dev
flutter build appbundle --flavor prod
flutter build ipa --flavor prod
To avoid typing --flavor every time, set a default in pubspec.yaml:
flutter:
default-flavor: dev
Read the flavor in Dart
Flutter exposes the flavor as a constant:
import 'package:flutter/services.dart';
final isDev = appFlavor == 'dev';
Flutter’s docs: the value “matches the name of the product flavor” (or scheme) and “if no flavor is specified during the build, appFlavor returns null.” Treat null as a configuration error, not as prod.
Firebase: one project per flavor
Create two Firebase projects. Then run flutterfire configure once per flavor, writing each to its own files. The FlutterFire CLI README says “You need to run flutterfire configure for every configuration type.” For dev:
flutterfire configure \
--project=myapp-dev \
--out=lib/firebase_options_dev.dart \
--android-package-name=com.example.app.dev \
--android-out=android/app/src/dev/google-services.json \
--ios-bundle-id=com.example.app.dev \
--ios-build-config=Debug-dev \
--ios-out=ios/dev/GoogleService-Info.plist
Then the same for prod with myapp-prod, com.example.app, src/prod and ios/prod. Repeat the iOS part for the Release and Profile configurations of each flavor.
On Android, the Google services plugin supports “variant-specific JSON files in build-type, product-flavor, or combined variant directories”, so src/dev/google-services.json is picked up for the dev flavor automatically.
In main.dart, choose the options by flavor:
import 'package:flutter/services.dart';
import 'firebase_options_dev.dart' as dev;
import 'firebase_options_prod.dart' as prod;
FirebaseOptions get firebaseOptions => switch (appFlavor) {
'dev' => dev.DefaultFirebaseOptions.currentPlatform,
'prod' => prod.DefaultFirebaseOptions.currentPlatform,
_ => throw StateError('Unknown flavor: $appFlavor'),
};
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: firebaseOptions);
runApp(const App());
}
For more on wiring Firebase itself, see Firebase for Flutter with Claude Code. For whether Firebase is the right backend at all, see Flutter Firebase vs Supabase.
Flavor-specific assets, icons and splash
- Assets:
pubspec.yamllets an asset path declareflavors:so it is only bundled for those flavors. Useful for a debug overlay image you never want in prod. - Icons:
flutter_launcher_iconsreadsflutter_launcher_icons-<flavor>.yaml. See Flutter app icons. - Splash:
flutter_native_splashtakes--flavors dev,prod. See Flutter splash screen.
Things that need per-flavor setup elsewhere
Flavors touch more than the build. Make a list and keep it in your project’s CLAUDE.md so nothing gets missed (see CLAUDE.md for Flutter):
- Sign in with Apple and Google OAuth clients for each bundle ID and SHA-1. See Flutter Google Sign-In with Firebase Auth.
- In-app purchase products and RevenueCat apps, if you test purchases against a separate setup.
- Deep link domains, if dev uses a staging domain.
- CI jobs: a dev build on every push, a prod build on tags. See Flutter CI/CD for App Store and Play.
Quick check
- Install both flavors on one device. Two icons, two names.
- Sign up in dev. The user appears only in the dev Firebase project.
- Trigger a test crash in dev. It appears only in dev Crashlytics.
flutter build ipa --flavor prodarchives with the prod bundle ID.
MobileKit’s setup skill creates dev and prod Firebase environments and the flavor wiring in one pass.
Sources read on the day this post was written: Flutter: Set up flavors for Android, Flutter: Set up flavors for iOS and macOS, Flutter: pubspec options, FlutterFire CLI README, Firebase: Google services plugin and file and Firebase: General best practices for dev workflows.