home_widget create

Scaffold placeholder native widget code for iOS and Android.

create

Scaffold placeholder native widget code for a new HomeScreen widget. Run this once per widget, then fill in the generated native files (or use generate to produce them from a schema).

dart run home_widget_cli create <Name> [options]

Behavior

  • <Name> is normalized to PascalCase and suffixed with HomeWidget. For example, create my_widget produces a class named MyWidgetHomeWidget.
  • Without --android or --ios, the CLI auto-detects which platforms to scaffold based on the presence of android/ and ios/ folders in the current directory.
  • Passing --android or --ios explicitly limits scaffolding to that platform.
  • For iOS, an App Group ID is written into entitlements and the widget placeholder code:
    • If --ios-app-group-id is provided, that value is used.
    • Otherwise, if stdin is interactive, you are prompted (default YOUR_APP_GROUP_ID).
    • If stdin is non-interactive, the default YOUR_APP_GROUP_ID is used.
  • The home_widget package is automatically added to your pubspec.yaml if it isn't already listed as a dependency.

After scaffolding, finish wiring up your project by following iOS Setup and Android Setup.

Options

OptionDescriptionDefault
--androidCreate Android widget placeholder structure.autodetect
--iosCreate iOS widget placeholder structure.autodetect
--ios-app-group-id=<id>iOS App Group ID to write into entitlements and widget placeholder code. If omitted and stdin is interactive, the CLI will prompt. If omitted and stdin is non-interactive, it defaults to YOUR_APP_GROUP_ID.prompt / YOUR_APP_GROUP_ID

Examples

Scaffold for every platform detected in the current Flutter project:

dart run home_widget_cli create Example

iOS only, with an explicit App Group ID:

dart run home_widget_cli create Example --ios --ios-app-group-id=group.com.example.app

Android only:

dart run home_widget_cli create Example --android