home_widget_generator
Generate native HomeScreen widget code from a Dart schema.
home_widget_generator
home_widget_generator lets you describe a HomeScreen widget once in Dart and have the matching native widget code generated for you. Instead of writing SwiftUI and Jetpack Glance by hand, you author a small annotated Dart class and the generator produces everything needed to render and update the widget on both platforms.
It builds on top of home_widget, which remains the runtime channel for sending data to and refreshing your widgets. The generator does not replace home_widget; it sits on top of it and removes the need to write platform-specific UI code yourself.
To run the generator, use the companion home_widget_cli tool. It discovers your annotated schemas with the Dart analyzer and writes the generated files into your Flutter project.
What gets generated
From a single annotated Dart class, the generator produces:
- A typed Dart helper (e.g.
MyWidgetHomeWidget) withsaveData(...),getData(),deleteData(...), andupdateWidget()methods. - An iOS widget extension using SwiftUI and WidgetKit, including the
TimelineProvider,TimelineEntry, andViewwired up to your App Group. - An Android widget using Jetpack Glance, including the
GlanceAppWidget,GlanceAppWidgetReceiver, and theappwidget-providerXML.
You only ever interact with the Dart helper from your app code. The native sources are dropped into your ios/ and android/ folders and compiled as part of your normal Flutter build.
Examples
The Greeting widget in Getting Started is part of a larger set of schemas in the generator_basics example app (install name: home_widget_generator). See the example README for full source and more previews.
Next steps
- Getting Started - install the generator and ship your first widget.
- Annotation - the
@HomeWidgetannotation and platform configuration options. - Widgets - the layout primitives (
HWColumn,HWRow,HWText,HWConditional, ...) you use to describe the UI. - Styling - colors, text styles, padding, and other shared building blocks.
- CLI - command reference for
home_widget_cli.











