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

VariantConstructorDescription
HWFixedColorHWColor.fixed(int value)A single ARGB color (e.g. 0xFFFF0000).
HWThemedColorHWColor.themed({light, dark})Resolves to light or dark based on the system color scheme.
HWDefaultColorHWDefaultColor(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

RoleDescription
contentPrimaryPrimary foreground content.
contentSecondarySecondary, less emphasized content.
contentTertiaryTertiary / decorative content.
contentAccentAccent / tint color.
defaultBackgroundThe default widget background.

Platform mapping