One Logo Pool Ball
WidgetKit · IOS API REFERENCE

TimelineProviderContext.EnvironmentVariants

struct · iOS 14.0+ · SDK 27.1

@dynamicMemberLookup struct EnvironmentVariants

A structure containing all varieties of environments where a widget could appear. When changes occur in environment values that affect display, like <doc://com.apple.documentation/documentation/swiftui/environmentvalues/colorscheme>, WidgetKit renders your widget's views. If your widget uses assets that take time to generate or depend on the specific environment they're rendered in, you can generate those assets in advance based on the new environment values. For example, in macOS, if the user has a mixture of @1x and @2x displays, the value for <doc://com.apple.documentation/documentation/swiftui/environmentvalues/displayscale> includes both scales. With these values, you can prepare your content in advance, if needed, to handle either type of display.

Members (2)

subscript · iOS 14.0+

subscript

TypeScript
subscriptDynamicMember(keyPath: SDKHandle): (Array<unknown>) | null
Swift declaration
subscript<T>(dynamicMember keyPath: WritableKeyPath<EnvironmentValues, T>) -> [T]? { get }

Returns the widget environment variants for a key path to an environment values instance.

subscript · iOS 14.0+

subscript

TypeScript
subscript(keyPath: SDKHandle): (Array<unknown>) | null
Swift declaration
subscript<T>(keyPath: WritableKeyPath<EnvironmentValues, T>) -> [T]? { get }

Returns the widget environment variants for a key path to an environment values instance.

Skipped declarations

No declarations were skipped in this snapshot.

All WidgetKit types →