DevOps & CI/CDMedium30 XP5 min read
What are Flutter flavors and how do you set them up?
TL;DR: Flavors (called product flavors on Android, schemes on iOS) let you build multiple versions of an app (dev, staging, prod) from the same codebase with different bundle IDs, API URLs, app icons, and names.
Full Answer
Flavors are essential for teams that need separate dev and prod apps installed simultaneously on the same device for testing without overwriting each other.
Setup Steps
- ▸Android: Add productFlavors block in android/app/build.gradle
- ▸iOS: Duplicate the Runner scheme in Xcode, rename to Development/Production
- ▸Create main_dev.dart and main_prod.dart with different environment configs
- ▸Use flutter_flavorizr package to automate both platforms simultaneously
- ▸Run: flutter run --flavor dev -t lib/main_dev.dart
🎯
Use flutter_flavorizr to generate flavor configuration for both Android and iOS from a single YAML config. It saves hours of manual Xcode scheme setup.
Code Examples
dartFlavor-based environment config
Output
// flutter run --flavor dev -t lib/main_dev.dart // flutter build apk --flavor prod -t lib/main_prod.dart
Common Mistakes
- ✗Hardcoding API URLs in the codebase — always use flavor-driven configuration
- ✗Not setting up separate bundle IDs — dev and prod apps overwrite each other on device
Interview Tip
💡
Show you know the difference between flavors (multiple app variants) and build modes (debug/profile/release). A prod flavor can be built in debug mode for testing.
#flavors#build-variants#environment#dev-prod