
Flutter Config
- 172 installs
- 29 repo stars
- Updated July 10, 2026
- dhruvanbhalara/skills
Set up Flutter flavors, env files, build variants, and platform-specific constants so dev, staging, and production mobile builds load the correct API keys, icons, and feature flags.
About
Explains Flutter configuration for multi-environment mobile apps: flavors, dart-define and env loading, Android/iOS plist and manifest differences, and safe secret handling so agents scaffold dev, staging, and prod variants without hard-coded endpoints or manual rebuild mistakes.
- Flavor and scheme setup
- Env-specific API base URLs
- Per-platform manifest tweaks
- Build-time vs runtime config split
- CI-friendly variant matrix
Flutter Config by the numbers
- 172 all-time installs (skills.sh)
- Ranked #504 of 1,039 Mobile Development skills by installs in the Skillselion catalog
- Data as of Jul 31, 2026 (Skillselion catalog sync)
npx skills add https://github.com/dhruvanbhalara/skills --skill flutter-configAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 172 |
|---|---|
| repo stars | ★ 29 |
| Last updated | July 10, 2026 |
| Repository | dhruvanbhalara/skills ↗ |
What it does
Set up Flutter flavors, env files, build variants, and platform-specific constants so dev, staging, and production mobile builds load the correct API keys, icons, and feature flags.
Files
Flavor Architecture
- Define three flavors:
dev,staging,prod - Use a single `main.dart` entry point for all flavors
- Pass flavor-specific configuration via
--dart-define-from-file:
flutter run --flavor dev --dart-define-from-file=config/dev.json
flutter run --flavor staging --dart-define-from-file=config/staging.json
flutter run --flavor prod --dart-define-from-file=config/prod.json- NEVER create separate
main_dev.dart,main_staging.dart,main_prod.dartentry points
Config JSON Structure
- Store per-flavor JSON config files in a
config/directory at project root:
config/
├── dev.json
├── staging.json
└── prod.json- Example
config/dev.json:
{
"FLAVOR": "dev",
"BASE_URL": "https://api-dev.example.com",
"APP_NAME": "MyApp Dev",
"ENABLE_LOGGING": "true",
"ENABLE_CRASHLYTICS": "false"
}- NEVER put secrets (API keys, signing credentials) in these JSON files — use CI-injected env vars or
flutter_secure_storage - Add
config/*.jsonto.gitignoreif they contain any environment-specific secrets; otherwise commit them for team convenience
Entry Point Pattern
// lib/main.dart
void main() {
const flavor = String.fromEnvironment('FLAVOR', defaultValue: 'dev');
AppConfig.init(flavor: Flavor.fromString(flavor));
runApp(const App());
}- Read all compile-time values via
String.fromEnvironment('KEY')orbool.fromEnvironment('KEY') - Use a sealed
Flavorenum:sealed class Flavor { dev, staging, prod } -
AppConfigis a singleton holding flavor, base URL, feature flags, and Firebase config
Environment Configuration
- Store per-flavor config in a centralized
AppConfigclass: -
baseUrl— API endpoint per environment -
enableLogging— verbose logging for dev only -
enableCrashlytics— disabled in dev -
appName— display name per flavor (e.g., "MyApp Dev", "MyApp") - All values come from the JSON file via
--dart-define-from-file— NO hardcoded per-flavor logic in Dart code - NEVER put secrets in the JSON config files — use
flutter_secure_storageor CI-injected env vars
Platform-Specific Flavor Setup
Android
- Define
flavorDimensionsandproductFlavorsinandroid/app/build.gradle:
flavorDimensions "environment"
productFlavors {
dev { dimension "environment"; applicationIdSuffix ".dev"; resValue "string", "app_name", "MyApp Dev" }
staging { dimension "environment"; applicationIdSuffix ".staging"; resValue "string", "app_name", "MyApp Staging" }
prod { dimension "environment"; resValue "string", "app_name", "MyApp" }
}iOS
- Create Xcode schemes for each flavor (Dev, Staging, Prod).
- Use xcconfig files for per-flavor bundle ID, display name, and signing.
- Map Flutter flavors to Xcode schemes in
ios/Runner.xcodeproj. - Swift Package Manager Integration: When configuring iOS flavors, Xcode schemes map package dependency configurations automatically. No CocoaPods
Podfilechanges are required for SPM. Ensure all dependency overrides are defined under Package Dependencies inside Xcode Runner project settings.
Firebase Per-Flavor
- Use separate Firebase projects per flavor (dev, staging, prod)
- Place
google-services.json(Android) andGoogleService-Info.plist(iOS) in flavor-specific directories - Use
flutterfire configurewith--projectflag for each environment
Build Commands
# Development
flutter run --flavor dev --dart-define-from-file=config/dev.json
# Staging
flutter run --flavor staging --dart-define-from-file=config/staging.json
# Production release
flutter build appbundle --flavor prod --dart-define-from-file=config/prod.json --release
flutter build ipa --flavor prod --dart-define-from-file=config/prod.json --releaseRules
- NEVER hardcode environment-specific values (URLs, API keys, feature flags)
- NEVER commit production secrets to the repository
- Every team member MUST be able to run any flavor locally with a single command
- CI/CD pipelines MUST specify both
--flavorand--dart-define-from-fileexplicitly - Use a single
main.dart— NEVER create separate entry points per flavor