glance_widget_platform_interface 2.0.0
glance_widget_platform_interface: ^2.0.0 copied to clipboard
A common platform interface for the glance_widget plugin.
2.0.0 #
Added: getWidgetData on the platform interface, plus
GlanceWidgetSnapshot, GlanceWidgetFormatException, MapReader and a
fromReader factory on every widget data type and its nested rows. The record
crosses as a JSON string: Android's JSON reader hands back every number as a
double once the static type is Object, and the standard codec would nest the
maps as Map<Object?, Object?>, so numbers are read as num throughout. See
#37.
Added: startLiveActivity, updateLiveActivity, endLiveActivity,
isLiveActivityRunning and areLiveActivitiesEnabled, with
LiveActivityContent and LiveActivityDismissal. A platform that answers
notImplemented produces an UnsupportedError for the three mutating calls
and false for the two queries.
LiveActivityContent validates before the channel: an empty title or status,
a progress outside 0.0-1.0, and content over ActivityKit's 4KB limit are all
refused here, where the offending field is still known. Past the channel the
same failures surface as a platform error naming nothing useful.
Added: forgetWidget(String widgetId), for dropping everything stored for
an id.
Added: GlanceTheme.useDynamicColor, sent over the wire as
useDynamicColor. Defaults to false, so existing themes are unaffected.
Honoured on Android 12+; elsewhere the theme's own colours are used, which is
why they remain required.
Breaking: the platform interface now models failure as an exception rather than a boolean.
Added #
updateBatchsends many widget updates in one call, withGlanceWidgetUpdatecarrying each widget's id, data and optional theme override. The batch theme travels once rather than once per widget.GlanceWidgetBatchExceptionandGlanceWidgetBatchFailurereport the widgets a batch could not update, leaving the ones that succeeded applied.
Changed #
- The 15 mutating members return
Future<void>and throwGlanceWidgetExceptionon a platform failure.isWidgetPushSupportedkeepsFuture<bool>because it asks a real question. getWidgetPushToken,getActiveWidgetIdsandgetBackgroundUpdateStatusthrow on a platform failure instead of answering a default that was indistinguishable from a real result.
Fixed #
ImageWidgetDataaccepted a widget with neitherimageUrlnorimageBase64, despite documenting that at least one is required, and drew a blank box.validate()now refuses it.ChartWidgetDataandGaugeWidgetDatawere silently notconst: aList.lengthassert in aconstconstructor is not const-evaluable, so everyconst ChartWidgetData(...)was aconst_eval_property_accesserror at the call site rather than at the constructor. Both are const again.- A rejected payload was thrown synchronously from an
asyncmethod, soupdate(...).catchError(...)never saw it. Rejections now arrive as a failed future.
Added #
WidgetData.validate()— checks the invariants that must hold before data crosses to the native side, throwingGlanceWidgetValidationExceptionnaming the offending field. Called at the channel boundary, so it runs in release builds too; the constructor asserts it complements are stripped there and cannot examine a list's length at all.
Removed #
MethodChannelGlanceWidget.throwOnError. Failures always throw; the originalPlatformExceptionis kept onGlanceWidgetException.originalException.
Changelog #
1.0.0 #
- Breaking:
WidgetDatais now asealed class— all 7 data types extend it - Added
WidgetData.templategetter for compile-time template identification - Added
dispose()toGlanceWidgetPlatformandMethodChannelGlanceWidget - Platform instance setter now auto-disposes old instance on swap
- Method channel namespace changed from
com.example.glance_widgettodev.glance.widget
0.6.0 #
- Added 4 new widget data models:
ImageWidgetData,ChartWidgetData,CalendarWidgetData,GaugeWidgetData - Added new enums:
ImageFit,ChartType,GaugeType - Added
CalendarEventandGaugeMetricdata classes - Added
deepLinkUrifield to all widget data classes - Added
updateImageWidget(),updateChartWidget(),updateCalendarWidget(),updateGaugeWidget()to platform interface - Added
configureTimelineRefresh()andcancelTimelineRefresh()for iOS timeline refresh - Added
completeWidgetConfiguration()for widget configuration flow - Added
configureandtoggleaction types toGlanceActionType - Added
itemId,value,itemIndexfields toGlanceWidgetAction - Updated SDK constraints to Dart >=3.6.0, Flutter >=3.27.0
0.4.0 #
- Added
GlanceTemplateenum for widget template types - Added
configureBackgroundUpdate()method for background updates - Added
cancelBackgroundUpdate()method - Added
getBackgroundUpdateStatus()method
0.3.1 #
- Dependency update for release
0.3.0 #
- Added input validation for widget data (empty titles, progress bounds, maxItems range)
- Improved documentation for all data types
0.2.0 #
- Added
getWidgetPushToken()method for iOS 26+ Widget Push Updates - Added
isWidgetPushSupported()method for runtime platform check - Prepared platform interface for iOS implementation
0.1.0 #
- Initial release
- Platform interface for Glance widget plugin
- Support for Simple, Progress, and List widget templates
- Theme configuration support
- Widget action event stream
- Custom exception classes for error handling