flutter_flavor_orchestrator 0.1.3 copy "flutter_flavor_orchestrator: ^0.1.3" to clipboard
flutter_flavor_orchestrator: ^0.1.3 copied to clipboard

A build-time orchestrator for managing Flutter flavors, native configurations, and provisioning files across Android and iOS platforms.

Flutter Flavor Orchestrator ๐ŸŽจ #

โ˜• Buy me a coffee on Ko-fi - If this package helps you, consider supporting my work!

pub package License: MIT Ko-fi

A powerful, enterprise-grade build-time orchestrator for managing Flutter flavors, native configurations, and provisioning files across Android and iOS platforms.

โœจ Features #

  • ๐ŸŽฏ Multiple Flavor Management - Easily configure dev, staging, production, and custom flavors
  • ๐Ÿ“ฑ Cross-Platform Support - Automatically updates Android and iOS native files
  • ๐Ÿ”ง Native File Manipulation - Intelligent modification of AndroidManifest.xml, build.gradle/build.gradle.kts, Info.plist, and more
  • ๐Ÿ”ฅ Firebase Integration - Automatic provisioning file management (google-services.json, GoogleService-Info.plist)
  • ๐Ÿ—๏ธ Clean Architecture - Enterprise-level code quality with separation of concerns
  • ๐Ÿ›ก๏ธ Safe Operations - Automatic backup and rollback on errors
  • ๐Ÿ“ YAML Configuration - Simple, declarative configuration files
  • ๐Ÿ” CLI Interface - Intuitive command-line tool with helpful output
  • โœ… Validated - Built-in configuration validation and error handling
  • ๐Ÿ“š Well Documented - Comprehensive documentation and examples

๐Ÿ“‹ Table of Contents #

๐Ÿš€ Installation #

Add flutter_flavor_orchestrator to your pubspec.yaml dev dependencies:

dev_dependencies:
  flutter_flavor_orchestrator: ^0.1.0

Then run:

flutter pub get

Activate the CLI tool globally (optional):

dart pub global activate flutter_flavor_orchestrator

โšก Quick Start #

1. Create Configuration File #

Create a flavor_config.yaml file in your project root:

dev:
  bundle_id: com.example.myapp.dev
  app_name: MyApp Dev
  metadata:
    API_URL: https://dev-api.example.com
  provisioning:
    android_google_services: configs/dev/google-services.json
    ios_google_service: configs/dev/GoogleService-Info.plist

production:
  bundle_id: com.example.myapp
  app_name: MyApp
  metadata:
    API_URL: https://api.example.com
  provisioning:
    android_google_services: configs/production/google-services.json
    ios_google_service: configs/production/GoogleService-Info.plist

2. Apply a Flavor #

# From your project root
flutter pub run flutter_flavor_orchestrator apply --flavor dev

3. Build Your App #

flutter clean
flutter pub get
flutter build apk  # or flutter build ios

That's it! Your app is now configured for the dev flavor.

โš™๏ธ Configuration #

Configuration File Location #

You can place your flavor configuration in either:

  1. Dedicated file: flavor_config.yaml in your project root (recommended)
  2. In pubspec.yaml: Under a flavor_config section

Configuration Options #

Each flavor supports the following configuration options:

Option Type Required Description
bundle_id String โœ… Bundle identifier (iOS) / Package name (Android)
app_name String โœ… Display name of the application
icon_path String โŒ Path to app icon assets
metadata Map โŒ Custom key-value pairs to inject into manifests
assets List โŒ Flavor-specific asset paths
dependencies Map โŒ Flavor-specific dependency overrides
provisioning Object โŒ Provisioning file configuration
android_min_sdk_version Integer โŒ Android minimum SDK version
android_target_sdk_version Integer โŒ Android target SDK version
android_compile_sdk_version Integer โŒ Android compile SDK version
ios_min_version String โŒ iOS minimum deployment target
custom_gradle_config Map โŒ Custom Gradle configuration snippets
custom_info_plist_entries Map โŒ Custom Info.plist entries

Provisioning Configuration #

provisioning:
  android_google_services: path/to/google-services.json
  ios_google_service: path/to/GoogleService-Info.plist
  additional_files:
    destination/path: source/path

Complete Example #

See example/flavor_config.yaml for a comprehensive configuration example.

๐ŸŽฎ CLI Usage #

The package provides a powerful command-line interface:

Apply Command #

Apply a flavor configuration to your project:

# Apply to both platforms
flutter_flavor_orchestrator apply --flavor dev

# Apply to Android only
flutter_flavor_orchestrator apply --flavor staging --platform android

# Apply to iOS only
flutter_flavor_orchestrator apply --flavor production --platform ios

# Enable verbose output
flutter_flavor_orchestrator apply --flavor dev --verbose

List Command #

List all available flavors:

flutter_flavor_orchestrator list

Info Command #

Display detailed information about a specific flavor:

flutter_flavor_orchestrator info --flavor production

Validate Command #

Validate all flavor configurations:

flutter_flavor_orchestrator validate

Help #

Display help information:

flutter_flavor_orchestrator --help

๐Ÿ”จ What Gets Modified #

Android #

When you apply a flavor, the following Android files are automatically updated:

android/app/src/main/AndroidManifest.xml

  • โœ๏ธ Package name (package attribute)
  • โœ๏ธ Application label (android:label)
  • โœ๏ธ Metadata entries (<meta-data> tags)

android/app/build.gradle or android/app/build.gradle.kts

  • โœ๏ธ Application ID (applicationId)
  • โœ๏ธ SDK versions (minSdkVersion, targetSdkVersion, compileSdkVersion)
  • โœ๏ธ Custom Gradle configuration
  • ๐Ÿ”„ Supports both Groovy (.gradle) and Kotlin (.gradle.kts) build scripts

android/app/google-services.json

  • ๐Ÿ“‹ Copied from configured path

iOS #

ios/Runner/Info.plist

  • โœ๏ธ Bundle display name (CFBundleDisplayName)
  • โœ๏ธ Bundle identifier (CFBundleIdentifier)
  • โœ๏ธ Minimum OS version (MinimumOSVersion)
  • โœ๏ธ Custom plist entries

ios/Runner.xcodeproj/project.pbxproj

  • โœ๏ธ Product bundle identifier (PRODUCT_BUNDLE_IDENTIFIER)
  • โœ๏ธ Deployment target (IPHONEOS_DEPLOYMENT_TARGET)

ios/Runner/GoogleService-Info.plist

  • ๐Ÿ“‹ Copied from configured path

๐Ÿ—๏ธ Advanced Configuration #

Custom Gradle Configuration #

Inject custom Gradle snippets:

custom_gradle_config:
  defaultConfig: |
    buildConfigField "String", "API_URL", "\"https://api.example.com\""
    buildConfigField "boolean", "DEBUG_MODE", "false"
  buildTypes: |
    release {
        shrinkResources true
        minifyEnabled true
    }

Custom Info.plist Entries #

Add custom iOS configuration:

custom_info_plist_entries:
  NSAppTransportSecurity:
    NSAllowsArbitraryLoads: true
  UIBackgroundModes:
    - fetch
    - remote-notification
  ITSAppUsesNonExemptEncryption: false

Metadata Injection #

Add custom metadata to both platforms:

metadata:
  API_URL: https://api.example.com
  API_KEY: your_api_key
  FEATURE_FLAG_X: true
  MAX_RETRIES: 3

Android: Added as <meta-data> tags in AndroidManifest.xml

iOS: Added as custom entries in Info.plist

๐Ÿ›๏ธ Architecture #

The package follows Clean Architecture principles:

lib/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ models/              # Data models
โ”‚   โ”‚   โ”œโ”€โ”€ flavor_config.dart
โ”‚   โ”‚   โ””โ”€โ”€ provisioning_config.dart
โ”‚   โ”œโ”€โ”€ processors/          # Platform processors
โ”‚   โ”‚   โ”œโ”€โ”€ android_processor.dart
โ”‚   โ”‚   โ””โ”€โ”€ ios_processor.dart
โ”‚   โ”œโ”€โ”€ utils/              # Utilities
โ”‚   โ”‚   โ”œโ”€โ”€ file_manager.dart
โ”‚   โ”‚   โ””โ”€โ”€ logger.dart
โ”‚   โ”œโ”€โ”€ config_parser.dart  # Configuration parsing
โ”‚   โ””โ”€โ”€ orchestrator.dart   # Main orchestrator
โ””โ”€โ”€ flutter_flavor_orchestrator.dart  # Public API

Key Components #

  • FlavorOrchestrator: Coordinates the entire process
  • ConfigParser: Parses and validates YAML configurations
  • AndroidProcessor: Handles Android-specific modifications
  • IosProcessor: Handles iOS-specific modifications
  • FileManager: Provides safe file operations with backup/rollback

๐Ÿ“š Examples #

Check out the example directory for a complete working example with:

  • โœ… Multiple flavor configurations
  • โœ… Firebase integration
  • โœ… Custom metadata
  • โœ… Platform-specific configurations
  • โœ… Complete Flutter app

๐Ÿ“– API Documentation #

Programmatic Usage #

You can also use the package programmatically in your Dart code:

import 'package:flutter_flavor_orchestrator/flutter_flavor_orchestrator.dart';

void main() async {
  final orchestrator = FlavorOrchestrator(
    projectRoot: '/path/to/project',
    verbose: true,
  );

  // Apply a flavor
  final success = await orchestrator.applyFlavor(
    'dev',
    platforms: ['android', 'ios'],
  );

  // List flavors
  final flavors = await orchestrator.listFlavors();

  // Validate configurations
  final valid = await orchestrator.validateConfigurations();
}

Core Classes #

  • FlavorConfig: Represents a complete flavor configuration
  • ProvisioningConfig: Provisioning file configuration
  • ConfigParser: Configuration parsing and validation
  • FlavorOrchestrator: Main orchestration logic

See the API documentation for detailed class and method documentation.

๐Ÿ”’ Safety Features #

Automatic Backups #

The orchestrator automatically creates backups of all modified files before making changes. If an error occurs, all changes are automatically rolled back.

Validation #

All configurations are validated before being applied:

  • โœ… Required fields presence
  • โœ… Bundle ID format validation
  • โœ… File existence checks
  • โœ… YAML syntax validation

Error Handling #

Comprehensive error handling with clear, actionable error messages:

  • ๐Ÿ”ด Missing configuration files
  • ๐Ÿ”ด Invalid bundle ID formats
  • ๐Ÿ”ด Missing native directories
  • ๐Ÿ”ด File operation failures

๐Ÿงช Testing #

The package includes a comprehensive test suite:

# Run all tests
dart test

# Run with coverage
dart test --coverage

๐Ÿค Contributing #

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

๐Ÿ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments #

  • Built with โค๏ธ by Alessio La Mantia
  • Inspired by the need for better flavor management in Flutter projects
  • Uses excellent packages: args, yaml, xml, path

๐Ÿ“ž Support #

๐Ÿ—บ๏ธ Roadmap #

  • โŒ Support for additional platforms (macOS, Windows, Linux)
  • โŒ Icon generation integration
  • โŒ Enhanced scheme management for iOS
  • โŒ Build flavor integration with flutter build commands
  • โŒ Interactive CLI mode
  • โŒ Configuration templates
  • โŒ Migration tools from other flavor solutions

Made with โค๏ธ for the Flutter community

1
likes
0
points
744
downloads

Publisher

unverified uploader

Weekly Downloads

A build-time orchestrator for managing Flutter flavors, native configurations, and provisioning files across Android and iOS platforms.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

args, path, xml, yaml

More

Packages that depend on flutter_flavor_orchestrator