Understanding Flavors
A concise guide to Digia UI flavors, initialization strategies, and recommended use cases.
Digia UI Flavors
Flavors in Digia UI SDK control how your app loads and manages configurations throughout different stages of development and deployment. Each flavor is designed for specific use cases and environments.
Overview
Flavors determine:
Where configuration is loaded from (server, cache, or local assets)
When configuration updates are fetched
How the app behaves in different environments
What strategy is used for initialization and caching
Available Flavors
1. Debug Flavor
Purpose: Development and testing environments where you need real-time configuration updates.
Flavor.debug(
branchName: 'feature-branch', // Optional
environment: Environment.production,
)Key Features
Real-time Updates - Loads configuration from the server in real-time
Immediate Testing - See configuration changes immediately without rebuilding
Branch Support - Optionally load from specific branches for feature development (Available only on Teams plan and above)
Development Focused - Perfect for active development workflows
Parameters
branchName(optional) - Specify a specific branch to load configuration from. Defaults tomainenvironment- Target environment
Use Cases
Active development and debugging
Testing new features before merging
Rapid prototyping and iteration
QA testing with live configuration changes
2. Staging Flavor
Purpose: Pre-Release testing environments when your changes are stable and can be handed to QA.
Key Features
Remote Updates - Can still receive configuration updates from server
Testing Focused - Ideal for final testing before production release
Stable Configuration - More stable than debug, less static than release
Parameters
environment- Target environment
Use Cases
Final QA testing before production deployment
User acceptance testing (UAT)
Performance testing with production-like setup
Client demos and previews
3. Versioned Flavor
Purpose: Loading specific configuration versions for consistency and rollback scenarios.
Key Features
Version Control - Load exact configuration versions
Consistency - Ensure all users see the same configuration
Rollback Support - Easily revert to previous working versions
A/B Testing - Different app versions can load different configurations
Parameters
version(required) - Specific version number to loadenvironment(optional) - Target environment (defaults to production)
Use Cases
A/B testing with different configuration versions
Rollback scenarios when issues are discovered
Maintaining consistency across different app releases
Gradual feature rollouts
Example
4. Release Flavor
Purpose: Production deployments with local assets for optimal performance and reliability.
⚠️ Note: Release flavor only works with the production environment and therefore does not have an option to choose environment. It is automatically configured for
Environment.production.
Key Features
Local Assets - Default Configuration loaded from app bundle to provide complete fallback
Optimal Performance - No network dependency for initial load
Maximum Reliability - Works even without internet connection
Production Only - Exclusively designed for production environments
Parameters
initStrategy(required) - Strategy for initializing and caching configurationappConfigPath(required) - Path to the app configuration asset file. Assets can be downloaded from Digia dashboard Release page.functionsPath(required) - Path to the functions configuration asset file
Dont forget to add the following in your Pubspec.yaml after putting above files in the assets folder
Init Strategies
NetworkFirstStrategy
Tries to fetch fresh configuration from network first. Your users will always see what you intended on the next app open
Falls back to cache if network fails
Falls back to local assets if cache fails
Best for apps that need the latest updates but require reliability
CacheFirstStrategy
Uses cached configuration first for immediate app startup
Falls back to local assets if cache unavailable
Updates cache in background during current session
First App Open: App loads with existing cached configuration while fetching latest updates in background
Second App Open: Users see the latest changes from previous background update
Best for apps prioritizing fast startup times
LocalFirstStrategy
Uses local assets only
No network requests for configuration
Maximum reliability and performance
Best for apps that rarely need configuration updates
Use Cases
Static app releases
Apps requiring maximum performance and reliability
Example
Environment Options
Environments in Digia UI work similar to Postman environments for APIs. They define different sets of environment variables that your APIs and configurations will use based on the selected environment.
Local - Uses local environment variables and configurations for local development
Development - Uses development server environment variables and API endpoints
Production - Uses production environment variables and live API endpoints
Important: Flavor and Environment are two different concepts:
Flavor determines HOW configuration is loaded (from server, cache, or assets)
Environment determines WHICH environment variables and API endpoints are used
Choosing the Right Combination
Local Development
Purpose: Active development on local machine with local services
Recommended: Debug Flavor + Local Environment
Configuration Source: Real-time from server
API Environment: Local endpoints and variables
Development Server Testing
Purpose: Testing with development servers and APIs
Recommended: Debug Flavor + Development Environment
Configuration Source: Real-time from server
API Environment: Development server endpoints and variables
Staging/QA Testing
Purpose: Pre-production testing with production-like setup
Recommended: Staging Flavor + Development Environment
Configuration Source: Stable server configuration
API Environment: Development/staging server endpoints
Production Deployment
Purpose: Live app with production APIs and services
Recommended: Release Flavor + Production Environment
Configuration Source: Local assets with optional network updates
API Environment: Production endpoints and variables
Best Practices
Local Development
dart
Development Testing
dart
Pre-Production Testing
dart
Production Release
dart
Conditional Flavors
This flavor system provides flexibility across all stages of app development while ensuring optimal performance and reliability for each environment.
Step-by-Step: Setting Up Flavors
Development Setup
Step 1: Create your main.dart with debug flavor
Step 2: Test with different branches (Teams plan and above)
Staging Setup
Step 1: Create staging configuration
Step 2: Update main.dart
Production Setup
Step 1: Download assets from Digia Studio
Go to app.digia.tech
Open your project
Navigate to Release section
Click Download Assets
Save
app_config.jsonandfunctions.json
Step 2: Add assets to project
Update pubspec.yaml:
Step 3: Configure release flavor
Step 4: Use in production
Multi-Environment Setup (Advanced)
Create a flexible configuration that adapts to build mode:
Run with different configurations:
Quick Reference
When to Use Each Flavor
Local development
Flavor.debug(environment: Environment.local)
N/A (server)
Development server testing
Flavor.debug(environment: Environment.development)
N/A (server)
Feature branch testing
Flavor.debug(branchName: 'feature-x')
N/A (server)
QA/Staging environment
Flavor.staging(environment: Environment.production)
N/A (server)
A/B testing
Flavor.versioned(version: 42)
N/A (server)
Production (latest config)
Flavor.release(...)
NetworkFirstStrategy
Production (fast startup)
Flavor.release(...)
CacheFirstStrategy
Production (offline-first)
Flavor.release(...)
LocalFirstStrategy
Environment Variables in Different Flavors
All flavors (except release) support environment selection:
⚠️ Note:
Flavor.release()always usesEnvironment.productionand cannot be changed.
Last updated