HWColor
Color values for HomeWidget — fixed ARGB, light/dark themed, and semantic system roles.
HWColor
HWColor is the base type for every color the generator emits. It is sealed/abstract — pick one of the variants below.
Variants
| Variant | Constructor | Description |
|---|---|---|
HWFixedColor | HWColor.fixed(int value) | A single ARGB color (e.g. 0xFFFF0000). |
HWThemedColor | HWColor.themed({light, dark}) | Resolves to light or dark based on the system color scheme. |
HWDefaultColor | HWDefaultColor(HWColorRole role) | A semantic system color picked via HWColorRole. |
HWColor.fixed
A literal ARGB color packed into a 32-bit integer.
HWText.fixed(
'Fixed Color',
style: HWTextStyle(color: HWFixedColor(0xFFFF0000)),
)
Background colors on the widget configuration take an HWColor directly:
HomeWidgetAndroidConfiguration(
backgroundColor: HWColor.fixed(0xFF0000FF),
)
HWColor.themed
Two HWColors — one for light mode, one for dark mode. Either side may itself be any HWColor.
HomeWidgetAndroidConfiguration(
backgroundColor: HWColor.themed(
light: HWColor.fixed(0xFFFF00FF),
dark: HWColor.fixed(0xFF00FF00),
),
)
HWDefaultColor
A semantic color tied to the system's widget palette. Useful when you want the widget to follow Apple's and Google's defaults instead of hardcoding values.
HWText.fixed(
'Primary',
style: HWTextStyle(color: HWDefaultColor(HWColorRole.contentPrimary)),
)
HWColorRole
| Role | Description |
|---|---|
contentPrimary | Primary foreground content. |
contentSecondary | Secondary, less emphasized content. |
contentTertiary | Tertiary / decorative content. |
contentAccent | Accent / tint color. |
defaultBackground | The default widget background. |
Platform mapping
- iOS — resolves to SwiftUI
Colorvalues such asColor.primaryandColor.accentColor. - Android — resolves to Glance
ColorProviderandGlanceTheme.colors.