TimelineProviderContext
An object that contains details about how a widget is rendered, including its size and whether it appears in the widget gallery.
Declaration
struct TimelineProviderContextOverview
When requesting timelines for a widget, WidgetKit passes the TimelineProvider a context object that includes details about how the widget appears. These details include:
The WidgetFamily; for example, WidgetFamily.systemSmall and WidgetFamily.systemMedium.
The size, in points, of the widget.
Variants of the environments where the widget might appear.
Whether the widget appears as a preview in the widget gallery.
If your widget uses assets that take time to generate or depend on the specific environment they’re rendered in, you can use the environment variants to generate those assets in advance. Some of the common environment properties to consider include:
colorScheme, where you use different assets for light and dark schemes.
displayScale, where your widget might appear in both @1x and @2x displays on macOS devices.
To be responsive when the environment changes, WidgetKit may render the widget’s view in advance. For example, WidgetKit renders both light and dark versions of the widget so that if the color scheme changes, the correct version is immediately available.