skills/flutter/flutter-config/SKILL.md
Configure app flavors (dev, staging, prod) with environment-specific settings via dart-define-from-file. Use when setting up build variants, per-flavor Firebase projects, or platform-specific configuration.
npx skillsauth add dhruvanbhalara/skills flutter-configInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
dev, staging, prodmain.dart entry point for all flavors--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
main_dev.dart, main_staging.dart, main_prod.dart entry pointsconfig/ directory at project root:
config/
├── dev.json
├── staging.json
└── prod.json
config/dev.json:
{
"FLAVOR": "dev",
"BASE_URL": "https://api-dev.example.com",
"APP_NAME": "MyApp Dev",
"ENABLE_LOGGING": "true",
"ENABLE_CRASHLYTICS": "false"
}
flutter_secure_storageconfig/*.json to .gitignore if they contain any environment-specific secrets; otherwise commit them for team convenience// lib/main.dart
void main() {
const flavor = String.fromEnvironment('FLAVOR', defaultValue: 'dev');
AppConfig.init(flavor: Flavor.fromString(flavor));
runApp(const App());
}
String.fromEnvironment('KEY') or bool.fromEnvironment('KEY')Flavor enum: sealed class Flavor { dev, staging, prod }AppConfig is a singleton holding flavor, base URL, feature flags, and Firebase configAppConfig class:
baseUrl — API endpoint per environmentenableLogging — verbose logging for dev onlyenableCrashlytics — disabled in devappName — display name per flavor (e.g., "MyApp Dev", "MyApp")--dart-define-from-file — NO hardcoded per-flavor logic in Dart codeflutter_secure_storage or CI-injected env varsflavorDimensions and productFlavors in android/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/Runner.xcodeprojgoogle-services.json (Android) and GoogleService-Info.plist (iOS) in flavor-specific directoriesflutterfire configure with --project flag for each environment# 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 --release
--flavor and --dart-define-from-file explicitlymain.dart — NEVER create separate entry points per flavordevelopment
Perform REST API networking operations (GET, POST, PUT, DELETE) using the lightweight and robust standard `http` package, including platform configurations and background parsing models.
development
Configure internationalization and localization support using Flutter's built-in l10n system, App Resource Bundle (ARB) files, and ICU formatting syntax.
development
Create model classes with fromJson/toJson using dart:convert and Dart 3 pattern matching. Use when manually mapping JSON to classes, parsing HTTP responses, or choosing between manual and code-generated serialization.
data-ai
Diagnose and fix Flutter layout constraint violations (RenderFlex overflow, unbounded height/width, ParentData misuse). Use when encountering layout exceptions, yellow-black overflow stripes, or red error screens.