---
title: Flavors
description: >-
  Generate a widget into some or all of your app's Flutter flavors, with a
  per-flavor iOS App Group.
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.page/abausg/home_widget/llms.txt
> Use this file to discover all available pages before exploring further.

# Flavors

On iOS, [Flutter flavors](https://docs.flutter.dev/deployment/flavors) are Xcode build configurations named `Debug-<flavor>`, `Release-<flavor>` and `Profile-<flavor>`, plus a scheme per flavor. On Android they are Gradle product flavors, each with its own source set under `android/app/src/<flavor>/`.

## Without `flavors:`

By default a widget exists in every flavor, with the base configuration everywhere. If your iOS project has flavored build configurations, the generator mirrors every Runner build configuration onto the widget extension target so the flavored project still builds — you don't need `flavors:` just to keep a flavored project compiling.

## The `flavors:` map

Add `flavors:` to generate the widget into only some flavors, or to override the iOS App Group per flavor:

```dart
@HomeWidget(
  name: 'Weather',
  flavors: {
    'dev': HomeWidgetFlavor(...),
    'stg': HomeWidgetFlavor(),
  },
  // ...
)
class Weather {}
```

The map is the **exact set of flavors the widget exists in** — a flavor not listed does not get the widget at all. Keys are Flutter flavor names and are matched case sensitively against your native project. `HomeWidgetFlavor()` means "this flavor, base configuration" — an entry with no overrides.

Given native flavors `dev`, `stg` and `prod`:

| Annotation | Result |
| --- | --- |
| no `flavors:` | Widget exists in `dev`, `stg` and `prod`, all with the base configuration. |
| `flavors: {'dev': HomeWidgetFlavor(...)}` | Widget exists in `dev` only. |
| `flavors: {'dev': HomeWidgetFlavor(...), 'stg': HomeWidgetFlavor()}` | Widget exists in `dev` and `stg`; `stg` uses the base configuration; nothing is generated for `prod`. |

## What can be overridden

Only the iOS App Group and provisioning profile are overridable per flavor — everything else (layout, data, localization, Android widget metadata) is shared across every flavor the widget is generated into. Android has no per-flavor overrides; the only thing that varies per flavor on Android is whether the widget exists there at all.

### `HomeWidgetFlavor`

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `iOS` | `HomeWidgetIOSFlavor?` | `null` | iOS overrides for this flavor. |

### `HomeWidgetIOSFlavor`

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `groupId` | `String?` | `null` | Overrides `HomeWidgetIOSConfiguration.groupId` for this flavor. |
| `provisioningProfile` | `String?` | `null` | Overrides `HomeWidgetIOSConfiguration.provisioningProfile` for this flavor: the profile the extension signs with in the flavor's build configurations the app signs manually. Takes the same `{appProfile}` and `{extensionName}` placeholders, e.g. `'{appProfile}.{extensionName}'`; because `{appProfile}` differs per configuration, Debug and Release can get different profiles from one value. See [Manual signing](/cli/generate#manual-signing-ios). |

`HomeWidgetIOSFlavor` requires the widget to already declare `iOS:` configuration — an `iOS:` override on a widget with no base `iOS:` configuration is a generator error.

## Example

```dart
@HomeWidget(
  name: 'Weather',
  iOS: HomeWidgetIOSConfiguration(groupId: 'group.com.example.app'),
  android: HomeWidgetAndroidConfiguration(),
  flavors: {
    'dev': HomeWidgetFlavor(
      iOS: HomeWidgetIOSFlavor(groupId: 'group.com.example.app.dev'),
    ),
    'prod': HomeWidgetFlavor(),
  },
  widget: HWText(HWString('city')),
)
class Weather {}
```

The widget is generated for `dev` and `prod` only — a flavor `stg` in the native project would not get the widget, and the generated helper does nothing there. In `dev`, the iOS extension uses the `group.com.example.app.dev` App Group. In `prod`, both platforms use the base configuration.

## What gets generated

### iOS

- Every Runner build configuration is mirrored onto the widget extension target, so a flavored iOS project keeps building even without flavor-specific values. Each mirrored configuration takes its bundle identifier, development team and entitlements path from the Runner configuration of the same name, whether those are set in the target, at project level, or in the `.xcconfig` the configuration is based on (`ios/Flutter/Debug-dev.xcconfig` style setups included).
- Flavored configurations get a `HW_FLAVOR_<NAME>` compilation condition (`<NAME>` is the flavor name, uppercased, with every non-alphanumeric character replaced by `_`), used to pick the right App Group at compile time. Other compilation conditions you set on the extension are kept; only the `HW_FLAVOR_` token is managed.
- On every run the generator resets `PRODUCT_BUNDLE_IDENTIFIER`, `CODE_SIGN_ENTITLEMENTS`, `DEVELOPMENT_TEAM`, `CODE_SIGN_STYLE`, `CODE_SIGN_IDENTITY` and `PROVISIONING_PROFILE_SPECIFIER` of the extension's configurations to the values derived from Runner, and says so when a value actually changed. The last four include their conditional variants such as `DEVELOPMENT_TEAM[sdk=iphoneos*]`; a variant Runner no longer has is removed. Treat those settings as generator-owned. Where Runner signs manually and the generator has no profile name for the extension, it leaves the extension's `CODE_SIGN_STYLE`, `CODE_SIGN_IDENTITY` and `PROVISIONING_PROFILE_SPECIFIER` as they are (Automatic on a newly created target) and warns. See [Manual signing](/cli/generate#manual-signing-ios) for how a Runner configuration that signs manually is mirrored.
- A per-flavor entitlements file is written at `ios/<Widget>HomeWidget.<flavor>.entitlements`, carrying that flavor's App Group.
- That App Group is also added to every Runner entitlements file the flavor's `Debug`, `Release` and `Profile` build configurations use. The base App Group goes into no Runner file at all: the unflavored configurations and the flavors missing from `flavors:` have no widget to share it with. A `CODE_SIGN_ENTITLEMENTS` that relies on a build variable other than `$(SRCROOT)` / `$(PROJECT_DIR)` cannot be resolved: the generator warns and leaves that file for you to update by hand.
- A flavor listed in `flavors:` whose Runner configuration signs with a file another flavor or the unflavored configurations also use — `Runner/Runner.entitlements` in a project made by `flutter create` — is moved onto a file of its own: `Runner/Runner-<flavor>.entitlements` next to the shared one, with `CODE_SIGN_ENTITLEMENTS` of that configuration pointed at it. The new file starts as a copy of the shared one, so keys such as `aps-environment` and the app's own App Groups carry over, minus the App Groups of the other flavors in `flavors:`; the flavor's App Group is then removed from the shared file. The base App Group is never removed from either file, since the app may use it itself. A flavor whose Debug and Release sign with different shared files gets a copy of each (`RunnerDebug-dev.entitlements`, `RunnerRelease-dev.entitlements`). A flavor that already signs with files of its own is left as it is.
- When a Runner file of a configuration without the widget still lists the base App Group — written there by an earlier version of the generator — `generate` points it out instead of removing it. Remove it by hand unless the app uses that group itself. The note is skipped for a file when another widget extension, embedded in a configuration signing with that file, still lists the group in its own entitlements.
- The widget is registered in the `WidgetBundle` only for the flavors listed in `flavors:` — omitted flavors don't compile the widget in at all.
- The app does not embed the extension in the build configurations of a flavor missing from `flavors:`, nor in the unflavored `Debug` / `Release` / `Profile`: the Runner configuration lists `<Widget>HomeWidget.appex` in `EXCLUDED_SOURCE_FILE_NAMES`, and the extension configuration sets `CODE_SIGNING_ALLOWED = NO` and `EXCLUDED_SOURCE_FILE_NAMES = "*"`, so those builds need no provisioning profile for the extension. The generator adds and removes only its own `.appex` entry and keeps any other value of `EXCLUDED_SOURCE_FILE_NAMES`; declaring the flavor later lifts all three again.

### Android

- Nothing in the generated Kotlin or resources differs per flavor.
- The widget's `<receiver>` is registered in `android/app/src/<flavor>/AndroidManifest.xml` only for the flavors listed in `flavors:`, and removed from `src/main/AndroidManifest.xml` — a widget with `flavors:` doesn't exist in `main` at all. A flavor manifest the generator creates starts with a comment marking it as generated; the generator adds and removes its own receivers in every source-set manifest it touches.

### Dart

The generated helper reads `package:flutter/services.dart`'s `appFlavor` at runtime and picks the App Group for the running flavor. The app has to be run with `--flavor <name>` for a flavored widget to exist at all: in a flavor missing from `flavors:`, and without `--flavor`, the widget exists on neither platform, so the helper leaves it alone on both. `saveData` and `deleteData` return without storing anything, `getData` answers every value's default, `updateWidget` answers `false`, and on Android `updatePreview` and `isRequestPinWidgetSupported` answer `false` while `requestPinWidget` does nothing.

## Diagnostics

- A flavor declared in `flavors:` that the native project doesn't have is an **error**, raised before anything is written: on iOS it names the `Debug-<flavor>`, `Release-<flavor>` and `Profile-<flavor>` build configurations to add to the app's Xcode project (`Runner.xcodeproj` unless you renamed it); on Android it names the missing product flavor and lists the ones found under `android/app/`. Android flavor detection reads the Gradle files as text, so a flavor declared in a way it cannot see is accepted once its source-set directory `android/app/src/<flavor>/` exists. Without a declared flavor the widget would be compiled out of every iOS build and dropped from every Android build, which is why this is not a warning.
- A native flavor not listed in `flavors:` is skipped silently — the widget just isn't generated for it. Its iOS build configurations are still mirrored onto the extension target, so the flavor's scheme does not fall back to another configuration, but the extension is neither signed nor embedded in its app.
- Validation errors: an empty `flavors:` map (the widget would exist in no flavor), a blank flavor name, an `iOS:` override on a flavor whose widget has no base `iOS:` configuration, an empty override `groupId` or `provisioningProfile`, or a `provisioningProfile` with a placeholder other than `{appProfile}` and `{extensionName}`.
