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 withHomeWidget. For example,create my_widgetproduces a class namedMyWidgetHomeWidget.- Without
--androidor--ios, the CLI auto-detects which platforms to scaffold based on the presence ofandroid/andios/folders in the current directory. - Passing
--androidor--iosexplicitly limits scaffolding to that platform. - For iOS, an App Group ID is written into entitlements and the widget placeholder code:
- If
--ios-app-group-idis 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_IDis used.
- If
- The
home_widgetpackage is automatically added to yourpubspec.yamlif it isn't already listed as a dependency.
After scaffolding, finish wiring up your project by following iOS Setup and Android Setup.
Options
| Option | Description | Default |
|---|---|---|
--android | Create Android widget placeholder structure. | autodetect |
--ios | Create 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