Flutter Flavors: Dev and Prod Builds With Firebase

· 5 min read

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.dev and com.example.app. Different IDs let both install at once.
  • Display name: “App Dev” and “App”.
  • Firebase project: myapp-dev and myapp-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:

  1. Create schemes. Product > Scheme > New Scheme, target Runner, name dev. Repeat for prod. In Manage Schemes, make sure Shared is checked.
  2. Duplicate build configurations. In the project’s Info tab, duplicate Debug as Debug-dev and Debug-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.
  3. Assign configurations to each scheme. For dev: Run, Test and Analyze use Debug-dev, Profile uses Profile-dev, Archive uses Release-dev. Same pattern for prod.
  4. Set bundle IDs. Runner target > Build Settings > Product Bundle Identifier, per configuration: com.example.app.dev for the dev ones, com.example.app for the rest. Register each ID in your Apple Developer account.
  5. Set display names. Add a user-defined build setting APP_DISPLAY_NAME with a value per configuration, and set CFBundleDisplayName in Info.plist to $(APP_DISPLAY_NAME).
  6. 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.yaml lets an asset path declare flavors: so it is only bundled for those flavors. Useful for a debug overlay image you never want in prod.
  • Icons: flutter_launcher_icons reads flutter_launcher_icons-<flavor>.yaml. See Flutter app icons.
  • Splash: flutter_native_splash takes --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):

Quick check

  1. Install both flavors on one device. Two icons, two names.
  2. Sign up in dev. The user appears only in the dev Firebase project.
  3. Trigger a test crash in dev. It appears only in dev Crashlytics.
  4. flutter build ipa --flavor prod archives 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.

Questions

How do I know which flavor is running in Dart?

Import package:flutter/services.dart and read appFlavor. It matches the Android product flavor or iOS scheme name, and is null if no flavor was specified.

Should dev and prod use the same Firebase project?

No. Firebase recommends using a separate Firebase project for each environment in your development workflow, so test data never mixes with real users.

Why do iOS flavor builds fail with a configuration error?

Flutter expects build configurations named like Debug-dev and Release-dev, with the flavor name in lowercase, and shared schemes with the same name as the flavor. If you use CocoaPods, the new configurations must also be listed in the Podfile.

Try it on your next idea

One payment, every update to this major version, and a refund window if it is not for you. Refund policy.