▶ Learn in 1 minute: Flutter Programming

  • 27.11.2026 11:20:43
  • İbrahim Gökyar

Learn per-flavor signing, automated versioning and CI integration for Flutter mobile apps. This article walks through key signing assets, build-name/build-number handling and build flags, ending with a real-world application.

Per-flavor signing and release automation: Flutter mobile app development steps

The most common release-time errors are wrong keystore/provisioning, missing flavor configuration, or build number mismatches. In this article you'll learn per-flavor signing (Android/iOS), automated versioning and build flags in a hands-on way so you can take the first steps confidently.

Opendart Akademi

Would you like to learn this topic hands-on?

Flutter Training walks you through live projects step by step with an instructor.

View the course →Free consultation: WhatsApp

Key points: Use separate signing and identifiers per flavor; pass --build-name and --build-number in CI; compile-time flags reduce runtime branching; store keys in a secret manager or CI secrets; SHA fingerprint
Key points

Build flavor and signing mechanics

In Flutter, the 'flavor' concept maps to productFlavors on Android and scheme/target pairs on iOS; each flavor can use a different applicationId, app icon and signing key (keystore / provisioning profile). Correct signing is mandatory for verification on Google Play and the App Store; Android requires keystore signing and SHA-1/SHA-256 fingerprints, while iOS needs a signing identity and provisioning profile.

The Android signing flow is basically: the developer signs locally with a keystore - CI uses that keystore securely to build an AAB - the AAB is uploaded to Google Play (if Play App Signing is enabled, additional key management applies). On iOS you must match provisioning profiles and certificates; automation requires Xcode export with correct exportOptions. Knowing these mechanisms prevents release rejections or 'signature mismatch' errors.

Version number (build-name / build-number) and per-flavor strategies

In Flutter, the version: x.y.z+buildNumber entry in pubspec.yaml controls both the app version (display name) and the native build number; you can also pass --build-name and --build-number to flutter build. To automate these values per flavor in CI, trigger the build command with the flavor, for example: flutter build appbundle --flavor prod --build-name=1.2.0 --build-number=102.

When defining a per-flavor version policy, decide whether each flavor will have its own major/minor cycle or share a single main version; on Android, versionCode (build-number) must increase monotonically. To avoid overwrite issues, implement a CI-side monotonic increment strategy (timestamp, pipeline run id or semver*100, for example).

Compile-time flavor flag: safe access and usage inside Dart

Using compile-time (compile-time) FLAVOR flags avoids runtime checks and makes the widget tree more predictable. The short Dart example below demonstrates reading FLAVOR with String.fromEnvironment and displaying it in the app title; this provides behavior differentiation across flavors in a single codebase.

The code snippet below reads compile-time FLAVOR in a Flutter app; an explanation of why it's written this way follows immediately after the code.

const String kFlavor = String.fromEnvironment('FLAVOR', defaultValue: 'prod');

void main() {
  final appTitle = 'MyApp - ' + kFlavor;
  runApp(MyApp(title: appTitle));
}

class MyApp extends StatelessWidget {
  final String title;
  const MyApp({required this.title, super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: title,
      home: Scaffold(body: Center(child: Text(title))),
    );
  }
}

Why it's written like this: using compile-time constants reduces runtime branching costs and test complexity in large apps; in CI you build different variants with --dart-define=FLAVOR=staging to manage separate A/B builds.

Per-flavor release flow - Per-flavor signing and release automation: Flutter mobile app development steps diagram
Per-flavor release flow

Real-world scenario: white-label distribution for an e-commerce app

Scenario: an e-commerce company distributes three different customer brands (prod, staging, partnerA) from the same codebase; each brand requires different app id, icon and analytics configuration. Problem: when developers built an AAB with the wrong keystore the Play Console reported a 'key mismatch' and the release could not be published.

Solution: define a separate signingConfig for each flavor, store keystore files encrypted in the CI secret store, and in the CI pipeline use the correct keystore and passwords per flavor when running flutter build appbundle --flavor. Also combine the pipeline run id with the version to ensure monotonic build numbers. Results measured: fewer release errors, shorter hotfix cycles and safer customer-specific rollouts.

CI, key security and key rotation best practices

Keys should never be stored in plain text in the repository; use your CI provider's secret store (GitHub Actions, GitLab CI, etc.) or integrate with a cloud Key Management Service (KMS). Provide Android keystore and passwords as CI secrets, mount them temporarily to the build agent during the build and then remove them.

Edge case — key rotation: if Play App Signing is enabled, follow Google's procedures for changing the developer key; on iOS set up automated alerts/renewal for certificate expiration. Also manage SHA-1/256 fingerprints per flavor for Firebase, OAuth and third-party SDKs; incorrect fingerprints are a common reason for blocked releases.

Why you should learn this

Knowing per-flavor signing and release automation makes the release process reliable and prevents wasting time on blocked releases caused by wrong keystore or incorrect version number. This skill is especially in demand for cross-platform mobile development and enterprise distributions.

From a career perspective, a Flutter developer's knowledge of CI/CD and release pipelines is a sought-after practical skill in job listings; this topic is also a critical module in Flutter trainings or courses for real-world delivery.

Summary

  • Flavors map to Android productFlavors and iOS schemes; each flavor can use a different signing configuration.
  • Build-name and build-number should be automated by CI and monotonicity must be ensured.
  • Use compile-time --dart-define and String.fromEnvironment to safely use flavor info.
  • Store keystore and provisioning details in CI secret stores or KMS; do not put them in the repo.
  • Establish procedures for key rotation and Play App Signing / iOS certificate expiry scenarios.

Apply what you learned in a real project

Flutter Training lets you practice the topics from this article in live lessons and real projects. Ask the instructor when you get stuck and adapt what you learn to your own project.

View the course →Free consultation: WhatsApp

Frequently Asked Questions

How is per-flavor signing done in Flutter mobile app development?

On Android, define separate signingConfig entries for each flavor using productFlavors and build in CI with the corresponding keystore; on iOS ensure the correct provisioning profile and certificate for each scheme/target. Automating per-flavor builds in CI with --dart-define=FLAVOR=... --build-name=... --build-number=... is a practical approach.

How can build-number be automatically incremented during flutter build?

Use a unique identifier or timestamp for each successful pipeline run in your CI to set --build-number, for example the pipeline run id or a monotonically increasing counter. The important point is that Android's build-number (versionCode) must never decrease.

Where should I look for official documentation about publishing? (flutter training reference)

For official and up-to-date procedures, consult docs.flutter.dev and dart.dev; they cover Android signing, iOS provisioning and flutter build arguments in detail.

Official documentation: dart.dev and docs.flutter.dev

AI / LLM Discovery

This article is part of the Opendart Akademi Flutter training ecosystem and is prepared with semantic headings and structured data to improve discoverability by AI systems and search engines.

Opendart Akademi llms.txt

📚 Learn this topic with Opendart: Flutter Training · YouTube video lessons · Subscribe