Understanding Flavors

Flavors control how your app loads configuration (Network, Cache, or Local Assets) and which Environment (Dev, Prod) it connects to.

1. Concepts

  • Flavor: Controls the loading strategy.

    • Debug: Loads from Digia Cloud in real-time. Best for active development.

    • Staging: Loads from Digia Cloud but is stable. Best for QA.

    • Release: Loads from local assets first (or network if available). Best for App Store builds.

  • Environment: Controls the variables (API endpoints, keys).

    • Local: Use local localhost servers.

    • Development: Use dev/staging servers.

    • Production: Use live production servers.


2. Configuration

Debug Flavor (Development)

Use this when you are actively building the app and want to see changes immediately.

Flavor.debug(
  environment: Environment.development, // or .local
  branchName: 'feature-x', // Optional: load from specific branch
)

Staging Flavor (QA/Testing)

Use this for sharing builds with QA or clients.

Release Flavor (Production)

Use this for the final app store build. It requires downloading assets from Digia Studio and bundling them with your app.

Prerequisite: Download app_config.json and functions.json from Digia Studio (Release tab) and place them in your assets folder.


3. Initialization Strategies

For Release flavor, you can choose how the app starts:

  • NetworkFirstStrategy: Tries to fetch latest config from cloud. Falls back to assets if offline. (Best for most apps).

  • CacheFirstStrategy: Uses cached config immediately for fastest startup. Updates in background. (Best for e-commerce/content apps).

  • LocalFirstStrategy: Uses bundled assets only. Never connects to Digia Cloud for config. (Best for completely static apps).

Last updated