flutter_native_widget library
Home screen widgets for Android and iOS, written in Dart.
Declare widgets with HomeScreenWidget, run dart run build_runner build
with flutter_native_widget_gen, then call the generated
initializeHomeWidgets() in main.
Classes
- FlutterNativeWidget
-
Runtime for widgets declared with
@HomeScreenWidget. - HomeScreenWidget
- Declares a home screen widget.
- NWAction
- What happens when the user taps an NWButton or the widget itself.
- NWAnalogClock
- A clock face with hands, kept up to date by the system.
- NWBox
- Sizing, padding, background and corner radius around an optional child.
- NWButton
- Makes child tappable.
- NWClock
-
The current time, kept up to date by the system even while the app is
closed (Android
TextClock, iOS timeline / timer text). - NWColor
- A color for generated native code, with an optional dark-mode variant.
- NWColumn
- Places children vertically.
- NWCondition
- A condition on a stored value, evaluated by the native widget.
- NWDateText
- A formatted date: today's date when field is null (updated by the system at midnight), otherwise the date stored in a dateTime field.
- NWField
- A piece of data the app writes and the widget shows.
- NWGradient
- A linear gradient for NWBox backgrounds.
- NWIcon
- A system icon: Material Icons on Android, SF Symbols on iOS.
- NWIf
- Shows child when condition holds, otherwise orElse.
- NWImage
- An image file whose path is stored in an image field.
- NWInsets
- NWList
-
A list of count items that scrolls on Android 12+. Like NWRepeat,
#in field keys inside child is the item index ({title#}), so its fields are declared withrepeat: count. - NWNode
- Base class of every element a home screen widget layout is made of.
- NWOption
- A choice the user makes for each copy of the widget: on Android when the widget is placed (and from "Reconfigure" on Android 12+), on iOS 17+ from "Edit widget".
- NWProgress
- A progress bar. field holds a number between 0 and max.
- NWRefresh
- Downloads JSON every every and saves values from it into fields, natively, while the app is closed.
- NWRepeat
-
Repeats child count times. Inside it,
#in field keys is replaced with the index:{title#}becomes{title0},{title1}, ... - NWRichText
- Text whose parts have different styles, e.g. a bold number next to a light unit:
- NWRow
- Places children horizontally. Follows the reading direction (RTL aware).
- NWSpacer
- Takes up the remaining space in a NWRow or NWColumn.
- NWSpan
-
One part of an NWRichText.
{key}placeholders work as in NWText. - NWStack
- Places children on top of each other.
- NWText
-
Text.
{key}placeholders are replaced with field values natively, e.g.'Count: {count}'. - NWTextStyle
- NWTimer
-
A live timer towards (or since) the time stored in a dateTime field.
Counts down before that moment and up after it. Ticks every second with
the app closed (Android
Chronometer, iOSText(_, style: .timer)). - RegisteredCallback
-
A
@WidgetCallbackfunction and the widget it listens to. - Size
- Holds a 2D floating-point size.
- Widget
- Describes the configuration for an Element.
- WidgetCallback
- Marks a top-level function as the handler for NWAction.callback taps.
- WidgetEvent
-
A tap on an
NWAction.callbackbutton. - WidgetLaunch
- The app was opened from a widget.
- WidgetSpec
- Native names and initial values of one widget. Generated for you.
- WidgetTimelineEntry
- One step of a widget timeline: from at on, these values are shown.
Enums
- NWActionKind
- NWAlignment
- NWConditionKind
- NWCrossAxisAlignment
- NWFieldType
- NWFontWeight
- NWImageFit
- NWMainAxisAlignment
- NWSize
- The sizes a widget supports.
- NWTextAlign
Typedefs
-
WidgetCallbackFunction
= FutureOr<
void> Function(WidgetEvent event)