# Add Dev and Production Build Flavors to a Flutter App

Yes. An agent adds dev and prod flavors: Android product flavors, iOS schemes and configurations, a per-flavor API URL in Dart, and a build of each.

[Run this on Rush](https://cloud.getrush.ai/run/add-build-flavors/flutter/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts by reading how the app is identified and configured today, because flavors have to change those places and only those. In an app like simplezhli/flutter_deer, `android/app/build.gradle` sets `applicationId "com.weilu.deer"` in `defaultConfig`, loads signing from `android/app/key.properties` for both `debug` and `release` build types, and declares no `productFlavors`; `android/app/src/main/AndroidManifest.xml` hard-codes `android:label="Flutter Deer"` and `android:icon="@mipmap/ic_launcher"`, and `android/app/src` already has `debug`, `main` and `profile` source sets. On iOS, `ios/Runner.xcodeproj` has the three stock configurations, Debug, Profile and Release, `ios/Runner/Info.plist` sets `CFBundleName` to Flutter Deer and `CFBundleIdentifier` to `$(PRODUCT_BUNDLE_IDENTIFIER)`, and `ios/Podfile` maps those three configurations in its `project 'Runner'` block. In Dart, `lib/res/constant.dart` has one environment switch, `inProduction = kReleaseMode`, and `lib/main.dart` passes a single base URL, `https://api.github.com/`, to `configDio` in `initDio()`.

On Android the agent adds a `flavorDimensions` entry and two `productFlavors`, `dev` with `applicationIdSuffix ".dev"` and `prod` with none, so the two builds install side by side on one device. Because the project is on Android Gradle Plugin 9.1.0 (`android/settings.gradle`), where `resValue` for `app_name` fails the build, it puts each flavor's name in `android/app/src/dev/res/values/strings.xml` and `android/app/src/prod/res/values/strings.xml` and changes the manifest's label to `@string/app_name`. The existing `mipmap-*` launcher icons stay as the prod icon, and the agent adds a `dev` copy under `android/app/src/dev/res/mipmap-*` with a visible badge so a tester can tell the builds apart; the signing configuration and the `release` build type's `minifyEnabled` and ProGuard settings are not touched.

On iOS, where the project file is the configuration, the agent edits `ios/Runner.xcodeproj/project.pbxproj` to add `Debug-dev`, `Profile-dev`, `Release-dev`, `Debug-prod`, `Profile-prod` and `Release-prod`, based on the existing `Debug.xcconfig` and `Release.xcconfig`, adds two shared schemes, `dev` and `prod`, under `xcshareddata/xcschemes` with Run and Test on the Debug configuration, Profile on Profile and Archive on Release, sets `PRODUCT_BUNDLE_IDENTIFIER` per configuration with a `.dev` suffix for the dev set, adds a user-defined `APP_DISPLAY_NAME` and points `CFBundleDisplayName` at it, and extends the `project 'Runner'` block in `ios/Podfile` so CocoaPods knows the six new configurations. In Dart it adds `lib/res/flavor_config.dart`, which reads `appFlavor` from `package:flutter/services.dart` and exposes the base URL and the display name, and changes `initDio()` in `main.dart` to take the URL from it; `Constant.inProduction` keeps meaning release mode, which is a different axis from the flavor and is used for log suppression.

The proof is a build of each flavor. The agent installs the Flutter SDK version the repository's own `.github/workflows/flutter-drive.yml` pins and the Android SDK in its sandbox, runs `flutter pub get`, `flutter analyze` with the repository's `analysis_options.yaml`, `flutter build apk --flavor dev --debug` and `flutter build apk --flavor prod --debug`, and reads the two APKs' manifests with the SDK's `aapt` to show the package names `com.weilu.deer.dev` and `com.weilu.deer` and the two labels. It runs the existing widget tests under `test/` with `flutter test` to show the Dart change broke nothing. An iOS build needs macOS and Xcode, which the Linux sandbox does not have, so for iOS the agent validates the project file by parsing it, checks that every configuration name follows the lowercase-suffix rule the Flutter CLI expects, and says in the pull request that the first `flutter run --flavor dev` on a Mac is the remaining check.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add two build flavors, dev and prod, to this Flutter app. Read pubspec.yaml, android/app/build.gradle, android/settings.gradle, android/app/src/main/AndroidManifest.xml, ios/Podfile, ios/Runner/Info.plist, ios/Runner.xcodeproj/project.pbxproj, lib/main.dart and lib/res/constant.dart first. On Android add productFlavors with an applicationIdSuffix for dev and per-flavor strings.xml app names instead of resValue, given the Android Gradle Plugin version in use. On iOS add Debug, Profile and Release configurations for each flavor, two shared schemes, per-configuration bundle identifiers and display names, and the Podfile configuration mapping. In Dart read appFlavor and move the API base URL and display name into a flavor config, keeping the existing release-mode switch for logging. Build both Android flavors in the sandbox, show their package names and labels, run flutter analyze and flutter test, and open a pull request that links the issue and says what still needs a Mac.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request on its own branch touching `android/app/build.gradle`, `android/app/src/main/AndroidManifest.xml`, new `strings.xml` and launcher icon files under `android/app/src/dev` and `android/app/src/prod`, `ios/Runner.xcodeproj/project.pbxproj`, two new scheme files, `ios/Runner/Info.plist`, `ios/Podfile`, a new `lib/res/flavor_config.dart` and a few lines in `lib/main.dart`. Signing, ProGuard rules, `pubspec.yaml` and every other Dart file are unchanged.

The description shows the `aapt` output for both debug APKs with their package names and labels, the `flutter analyze` and `flutter test` summaries, and a table of the six iOS configurations with their bundle identifier and display name. A separate section says plainly which parts were built and which were only validated, and gives the exact commands to run on a Mac: `flutter run --flavor dev` and `flutter run --flavor prod`.

Before merging, a reviewer opens the project in Xcode once to confirm the schemes appear and are shared, decides the dev base URL, which the pull request leaves as a clearly marked placeholder beside the production one, and registers the `.dev` bundle identifier in the Apple developer account, which no agent can do.

## Run it on every Linear issue labelled agent

In the console, an automation with a `linear` trigger on `linear.issue.labeled` and the label `agent` starts one run per labelled issue in the Project that holds the app, with the issue text as its context. An issue that says "we need a dev build that points at staging and installs beside the store build" is enough for the agent to read `build.gradle` and `main.dart` and do the rest. Changes made by an app integration never fire the trigger, so the agent's own comments on the issue start nothing.

From your own server, the same run is one `POST /o/{org}/sessions` per issue with this body, the repository in `resources` and the issue's `https://linear.app/<workspace>/issue/<ID>` URL there too, read through your Linear connection into the prompt. Send a `request_id`, a UUID v5 of the issue id, so a redelivered event does not start a second run.

## Why run it on Rush?

Flavors touch three toolchains at once, and each has a trap: Gradle 9's `resValue` failure for `app_name`, Xcode configuration names that the Flutter CLI only recognises in lowercase, a Podfile that silently ignores a configuration it was not told about. The agent reads the plugin version, the project file and the Podfile before editing and builds what it can build, so the pull request arrives with two APKs' worth of evidence instead of a diff and a hope.

On Rush the Flutter and Android SDK installs, the two builds and the tests run in the agent's own sandbox, where they can take the time they take without occupying a developer's machine, and the build output stays in the transcript. The same body on another Flutter app reads that app's identifiers and plugin version and makes the same decisions from them.

## Frequently asked questions

### Can both flavors be installed on one phone?

Yes. The dev flavor gets `applicationIdSuffix ".dev"` on Android and a `.dev` bundle identifier suffix on iOS, so `com.weilu.deer.dev` and `com.weilu.deer` are different apps to the operating system, with different names and, for Android, a badged icon. The prod flavor keeps the current identifier, so the store listing is unaffected.

### What about iOS, if the agent cannot build it?

The Linux sandbox has no Xcode, so the agent edits the project file, the schemes, `Info.plist` and the Podfile, validates the project file parses and the configuration names follow the convention the Flutter CLI matches on, and says in the pull request that `flutter run --flavor dev` on a Mac is the remaining check. It does not claim an iOS build it did not make.

### How does the Dart code know which flavor is running?

Through `appFlavor` from `package:flutter/services.dart`, which the Flutter tool sets from `--flavor` and which is `null` when no flavor is given. The new `flavor_config.dart` maps it to a base URL and a display name and falls back to prod when it is `null`, so plain `flutter run` keeps working. Release versus debug stays on `kReleaseMode`, as `Constant.inProduction` already does.

### Does this change signing or the release build?

No. `signingConfigs.release` and the `release` build type's shrinking and ProGuard settings in `build.gradle` are left as they are, and both flavors use them, so `flutter build appbundle --flavor prod --release` produces the same kind of artifact as before, under the same keystore from `key.properties`.

### Why strings.xml instead of resValue for the app name?

Because `android/settings.gradle` pins the Android Gradle Plugin at 9.1.0, and from 9.0 a `resValue` for `app_name` fails the build. A `strings.xml` per flavor source set does the same job and is what the Flutter documentation now shows; the manifest's `android:label` changes to `@string/app_name` to pick it up.

## More Flutter jobs

- [Add Test Coverage Reporting to a Flutter App's CI](https://getrush.ai/run/add-coverage-to-ci/flutter/)
- [Add Crash Reporting to a Flutter App](https://getrush.ai/run/add-crash-reporting/flutter/)
- [Add a Dark Theme Setting to a Flutter App from a Linear Issue](https://getrush.ai/run/add-dark-theme/flutter/)

## More jobs like this: Turn a Linear label into a PR

- [Add a Bulk Export Action to a Filament Table from a Linear Issue](https://getrush.ai/run/add-bulk-export/filament/)
- [Add Bulk Inserts to a sqlc and pgx Project](https://getrush.ai/run/add-bulk-inserts/sqlc/)
- [Add a Bundle Size Check to a TypeScript Library from a Linear Issue](https://getrush.ai/run/add-bundle-size-check/typescript-library/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
