---
title: Annotation
description: The @HomeWidget annotation and its platform configuration options.
---
> ## 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.

# Annotation

Every generated widget starts with a class annotated with `@HomeWidget(...)`. The annotation describes the widget's identity, its UI, and how it should be configured on each platform.

```dart
import 'package:home_widget_generator/home_widget_generator.dart';

@HomeWidget(
  name: 'Widget Configuration',
  description: 'A widget with configuration options',
  iOS: HomeWidgetIOSConfiguration(
    groupId: 'group.es.antonborri.hwGeneratePlayground',
    supportedFamilies: [
      HWWidgetFamily.systemSmall,
      HWWidgetFamily.systemMedium,
    ],
  ),
  android: HomeWidgetAndroidConfiguration(
    packageName: 'com.example',
    minWidth: 100,
    minHeight: 50,
    targetCellWidth: 2,
    targetCellHeight: 1,
    resizeMode: HWAndroidResizeMode.horizontal,
    widgetCategory: HWAndroidWidgetCategory.homeScreen,
    updatePeriodMillis: 3600000,
  ),
)
class ConfigurationOptions {}
```

## `@HomeWidget`

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `name` | `String` | required | The widget's name. Maps to the `kind` on iOS WidgetKit and the receiver `label` on Android. |
| `description` | `String?` | `null` | Description shown in the iOS and Android widget gallery. |
| `widget` | `HWWidget?` | `null` | The widget UI tree, built from the [Widgets](/generator/widgets/hw-adaptive) primitives. |
| `dartOutput` | `String?` | `null` | Override the path of the generated Dart helper file. |
| `android` | `HomeWidgetAndroidConfiguration?` | `null` | Android-specific configuration (see below). |
| `iOS` | `HomeWidgetIOSConfiguration?` | `null` | iOS-specific configuration (see below). |
| `localization` | `HomeWidgetLocalization?` | `null` | Default locale, supported locales, and translations of the gallery name and description. See [Localization](/generator/localization). |
| `widgetUrl` | `String?` | `null` | URL the app is opened with when the widget is tapped. See [Widget Clicks](/generator/widget-url). |
| `flavors` | `Map<String, HomeWidgetFlavor>?` | `null` | Restricts which Flutter flavors the widget is generated into, with per-flavor overrides. See [Flavors](/generator/flavors). |
| `useLiveDataInPreview` | `bool` | `true` | Whether the widget gallery preview reads stored data ahead of `previewValue`. Overridable per platform. See [Previews](/generator/previews). |

A `localization:` block is required as soon as the widget uses a localized string
(`HWText.localized` or `HWString.localized`) — it supplies the default locale
every fallback resolves to. See [Localization](/generator/localization) for the
full workflow.

## `HomeWidgetAndroidConfiguration`

Maps to [`AppWidgetProviderInfo`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo) on Android.

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `packageName` | `String?` | auto-detected | App package name. If omitted, the generator infers it from your Android project. |
| `minWidth` | `int?` | `null` | Default width in dp. Maps to [`minWidth`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#minWidth). |
| `minHeight` | `int?` | `null` | Default height in dp. Maps to [`minHeight`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#minHeight). |
| `minResizeWidth` | `int?` | `null` | Minimum resizable width in dp. Maps to [`minResizeWidth`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#minResizeWidth). |
| `minResizeHeight` | `int?` | `null` | Minimum resizable height in dp. Maps to [`minResizeHeight`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#minResizeHeight). |
| `maxResizeWidth` | `int?` | `null` | Maximum resizable width in dp (Android 12+). Maps to [`maxResizeWidth`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#maxResizeWidth). |
| `maxResizeHeight` | `int?` | `null` | Maximum resizable height in dp (Android 12+). Maps to [`maxResizeHeight`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#maxResizeHeight). |
| `targetCellWidth` | `int?` | `null` | Default width in cells (Android 12+). Maps to [`targetCellWidth`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#targetCellWidth). |
| `targetCellHeight` | `int?` | `null` | Default height in cells (Android 12+). Maps to [`targetCellHeight`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#targetCellHeight). |
| `resizeMode` | `HWAndroidResizeMode?` | `null` | How the widget can be resized. Maps to [`resizeMode`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#resizeMode). |
| `widgetCategory` | `HWAndroidWidgetCategory?` | `null` | Where the widget can be shown. Maps to [`widgetCategory`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#widgetCategory). |
| `updatePeriodMillis` | `int?` | `null` | Refresh interval in ms. Maps to [`updatePeriodMillis`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#updatePeriodMillis). |
| `useGlanceTheme` | `bool` | `true` | Wraps the generated Glance UI in `GlanceTheme { ... }`. |
| `backgroundColor` | `HWColor?` | `HWDefaultColor(HWColorRole.defaultBackground)` | Background color applied via `GlanceModifier.background(...)`. See [`HWColor`](/generator/styling/hw-color). |
| `applyContentPadding` | `bool` | `true` | Applies a default 16.dp root padding. |
| `fillWidgetContent` | `bool` | `true` | Applies `GlanceModifier.fillMaxSize()` to the root. |
| `widgetUrl` | `String?` | `null` | Overrides `@HomeWidget.widgetUrl` on Android. See [Widget Clicks](/generator/widget-url). |
| `openAppOnTap` | `bool` | `true` | If `false`, the widget root is not made clickable at all, so tapping it does nothing — even when a `widgetUrl` is set. See [Widget Clicks](/generator/widget-url). |
| `useLiveDataInPreview` | `bool?` | `null` | Overrides `@HomeWidget.useLiveDataInPreview` on Android. `null` inherits it. See [Previews](/generator/previews). |
| `autoUpdatePreview` | `bool` | `true` | Whether the plugin registers the generated preview with the launcher automatically on app start (Android 15+). See [Previews](/generator/previews#registering-the-preview-on-android). |

## `HomeWidgetIOSConfiguration`

Maps to [`WidgetConfiguration`](https://developer.apple.com/documentation/widgetkit/widgetconfiguration) on iOS.

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `groupId` | `String` | required | App Group ID used to share data between the app and the widget extension. |
| `supportedFamilies` | `List<HWWidgetFamily>?` | `systemSmall`, `systemMedium`, `systemLarge` (WidgetKit's default) | Restricts which [`WidgetFamily`](https://developer.apple.com/documentation/widgetkit/widgetfamily) values are supported. Maps to [`StaticConfiguration.supportedFamilies`](https://developer.apple.com/documentation/widgetkit/staticconfiguration/supportedfamilies(_:)). Also the set of families [`HWSizeAdaptive`](/generator/widgets/hw-size-adaptive) must cover on iOS. |
| `backgroundColor` | `HWColor?` | `null` | Background color for the widget container. See [`HWColor`](/generator/styling/hw-color). |
| `applyContentPadding` | `bool` | `true` | If `false`, calls `contentMarginsDisabled()` to opt out of system padding. |
| `widgetUrl` | `String?` | `null` | Overrides `@HomeWidget.widgetUrl` on iOS. See [Widget Clicks](/generator/widget-url). |
| `useLiveDataInPreview` | `bool?` | `null` | Overrides `@HomeWidget.useLiveDataInPreview` on iOS. `null` inherits it. See [Previews](/generator/previews). |
| `provisioningProfile` | `String?` | `null` | Name of the provisioning profile the widget extension signs with in every build configuration the app signs manually. May hold the placeholders `{appProfile}`, the app's profile name in that configuration, and `{extensionName}`, the extension target's name, e.g. `'{appProfile}.{extensionName}'`; because `{appProfile}` differs per configuration, Debug and Release can get different profiles from one value. `null` is `'{appProfile} {extensionName}'`, e.g. `App Prod WeatherHomeWidget`. Overridable per flavor. See [Manual signing](/cli/generate#manual-signing-ios). |

## `HWWidgetFamily`

The values accepted by `supportedFamilies`, each mapping to a [`WidgetFamily`](https://developer.apple.com/documentation/widgetkit/widgetfamily) case. `HWSizeAdaptive` uses the same enum to key its slots — see [`HWSizeAdaptive`](/generator/widgets/hw-size-adaptive).

| `HWWidgetFamily` | `WidgetFamily` | Minimum OS |
| --- | --- | --- |
| `systemSmall` | `.systemSmall` | iOS 14 |
| `systemMedium` | `.systemMedium` | iOS 14 |
| `systemLarge` | `.systemLarge` | iOS 14 |
| `systemExtraLarge` | `.systemExtraLarge` | iOS 15 (iPad) |
| `systemExtraLargePortrait` | `.systemExtraLargePortrait` | iOS / iPadOS 27 |
| `accessoryCircular` | `.accessoryCircular` | iOS 16 |
| `accessoryRectangular` | `.accessoryRectangular` | iOS 16 |
| `accessoryInline` | `.accessoryInline` | iOS 16 |

## `HomeWidgetFlavor`

Value of an entry in `@HomeWidget.flavors`. `HomeWidgetFlavor()` means "this flavor, base configuration". See [Flavors](/generator/flavors).

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

## `HomeWidgetIOSFlavor`

Per-flavor overrides for `HomeWidgetIOSConfiguration`. Requires the widget to declare `iOS:` configuration. See [Flavors](/generator/flavors).

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `groupId` | `String?` | `null` | Overrides `HomeWidgetIOSConfiguration.groupId` for this flavor. |
| `provisioningProfile` | `String?` | `null` | Overrides `HomeWidgetIOSConfiguration.provisioningProfile` for this flavor. Takes the same `{appProfile}` and `{extensionName}` placeholders. See [Manual signing](/cli/generate#manual-signing-ios). |
