Understanding Flavors
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({
String? branchName,
Environment 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 tomain
environment
- 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.
Flavor.staging({
Environment environment = Environment.production,
})
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.
Flavor.versioned({
required int version,
Environment environment = Environment.production,
})
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
// Load specific version
Flavor.versioned(
version: 42,
environment: Environment.production,
)
// Load version for testing environment
Flavor.versioned(
version: 35,
environment: Environment.development,
)
4. Release Flavor
Purpose: Production deployments with local assets for optimal performance and reliability.
Flavor.release({
required DSLInitStrategy initStrategy,
required String appConfigPath,
required String functionsPath,
})
⚠️ 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
# To add assets to your application, add an assets section, like this: assets: - assets/
Init Strategies
PrioritizeNetwork
DSLInitStrategy.prioritizeNetwork(timeoutInMs: 3000)
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
PrioritizeCache
DSLInitStrategy.prioritizeCache()
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
PrioritizeLocal
DSLInitStrategy.prioritizeLocal()
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
// Release flavor with network priority
Flavor.release(
initStrategy: DSLInitStrategy.prioritizeNetwork(timeoutInMs: 3000),
appConfigPath: 'assets/config/app_config.json',
functionsPath: 'assets/config/functions.json',
)
// Release flavor with local-only strategy
Flavor.release(
initStrategy: DSLInitStrategy.prioritizeLocal(),
appConfigPath: 'assets/config/app_config.json',
functionsPath: 'assets/config/functions.json',
)
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.
dart
enum Environment {
local,
development,
production,
}
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
// Local development with local APIs
Flavor.debug(
branchName: 'feature/my-feature',
environment: Environment.local,
)
Development Testing
dart
// Development server testing
Flavor.debug(
branchName: 'feature/my-feature',
environment: Environment.development,
)
Pre-Production Testing
dart
// QA testing with development APIs
Flavor.staging(
environment: Environment.development,
)
Production Release
dart
// Production deployment with production APIs
Flavor.release(
initStrategy: DSLInitStrategy.prioritizeNetwork(timeoutInMs: 2000),
appConfigPath: 'assets/app_config.json',
functionsPath: 'assets/functions.json',
)
// Note: Release flavor automatically uses Environment.production
Conditional Flavors
Flavor getFlavor() {
if (kDebugMode) {
return Flavor.debug(environment: Environment.local);
} else if (kReleaseMode) {
return Flavor.release(
initStrategy: DSLInitStrategy.prioritizeNetwork(timeoutInMs: 2000),
appConfigPath: 'assets/app_config.json',
functionsPath: 'assets/functions.json',
);
} else {
return Flavor.staging(environment: Environment.development);
}
}
This flavor system provides flexibility across all stages of app development while ensuring optimal performance and reliability for each environment.
Last updated