Contents

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 TimelineProviderContext

Overview

When requesting timelines for a widget, WidgetKit passes the TimelineProvider a context object that includes details about how the widget appears. These details include:

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.

Topics

Preparing Preview Content

Accessing Size Attributes

Accessing Environment Variations

See Also

Timeline updates