Skip to content

Flavor Manager

The flavor command manages app flavors (build variants) using flutter_flavorizr. It handles flavor configuration, native platform setup (Android product flavors, iOS schemes), IDE configurations, and entry point generation.

Subcommands

flavor list-apps

Lists all apps in the workspace that have flavor configurations:

bash
dart run monorepo_toolkit flavor list-apps

flavor list

Lists all configured flavors for a specific app:

bash
dart run monorepo_toolkit flavor list --app template_app

Displays each flavor with its app name, Android application ID, and iOS bundle ID.

flavor add

Adds a new flavor to an app:

bash
# Basic usage
dart run monorepo_toolkit flavor add --app template_app --name qa

# With custom app name suffix and bundle ID suffix
dart run monorepo_toolkit flavor add \
  --app template_app \
  --name qa \
  --app-name "[QA]" \
  --suffix ".qa"

# Add and immediately generate native files
dart run monorepo_toolkit flavor add --app template_app --name qa --generate
FlagDescription
--app / -aThe app name (required)
--name / -nThe flavor name, e.g., qa, uat, demo (required)
--app-nameCustom app name suffix. Defaults to [FLAVOR_NAME]
--suffix / -sBundle ID suffix. Defaults to .<flavor_name>
--generate / -gRun flutter_flavorizr after adding

Flavor names must start with a lowercase letter and contain only lowercase letters, numbers, and underscores.

flavor generate

Runs flutter_flavorizr to generate native platform files for all configured flavors:

bash
dart run monorepo_toolkit flavor generate --app template_app

# Force regeneration even if inputs haven't changed
dart run monorepo_toolkit flavor generate --app template_app --force

# Check which flavors need regeneration without making changes
dart run monorepo_toolkit flavor generate --app template_app --check

The generate command runs up to four steps:

  1. flutter_flavorizr for native Android/iOS flavor files and launcher icons
  2. Native splash screen generation (if configured)
  3. IDE configuration generation (VSCode launch.json, JetBrains run configs)
  4. Flavor-based main_<flavor>.dart entry point files

Each step can be toggled with --no-splash, --no-icons, --no-ide-configs, or --no-main-files.

flavor sync

Synchronizes flavor settings between the global flavors.yaml config and individual app configurations:

bash
# Initialize global settings from existing app configs
dart run monorepo_toolkit flavor sync --init

# Sync global settings to all apps (add missing flavors)
dart run monorepo_toolkit flavor sync

# Sync a specific app only
dart run monorepo_toolkit flavor sync --app template_app

# Sync from app configs back to global settings
dart run monorepo_toolkit flavor sync --from-apps

Android/iOS mapping

Each flavor maps to platform-specific identifiers:

PlatformWhat it maps toExample
AndroidapplicationId suffix in build.gradlecom.example.app.staging
iOSBundle identifier in Xcode schemecom.example.app.staging

The generate command creates all necessary native files: Android productFlavors blocks, iOS build configurations, and Xcode schemes.

Default flavors

When initializing with flavor sync --init, the default flavors are:

  • development (suffix .development)
  • staging (suffix .staging)
  • production (no suffix)

Workflow

  1. Define flavors globally in flavors.yaml
  2. Run dart run monorepo_toolkit flavor sync --init to create the global config
  3. Add new flavors with dart run monorepo_toolkit flavor add
  4. Generate native files with dart run monorepo_toolkit flavor generate
  5. Run the app with flutter run --flavor development

Melos shortcuts

bash
melos run flavor:list       # List flavors for an app
melos run flavor:add        # Add a new flavor
melos run flavor:generate   # Generate native flavor files
melos run flavor:sync       # Sync global and app configs

Built by Banua Coder