HWText

Render fixed or data-bound text.

HWText

Renders a string, either hardcoded or bound to a widget data field. Both constructors accept an optional HWTextStyle and HWTextAlign.

Constructors

HWText.fixed

const HWText.fixed(String content, {HWTextStyle? style, HWTextAlign? textAlign})

Hardcoded literal — the value is baked into the generated native code.

HWText.fixed('Hello World')

HWText (data-bound)

const HWText(HWDataType data, {HWTextStyle? style, HWTextAlign? textAlign})

Reads the value from widget storage at runtime. Add the matching field to the entry by using it here or via HWDataOnly.

HWText(HWString('greeting'))

Styled example

HWText.fixed(
  '46',
  style: HWRoleTextStyle(
    role: HWTextStyleRole.title,
    color: HWDefaultColor(HWColorRole.contentPrimary),
    fontWeight: HWFontWeight.bold,
  ),
)

Parameters

NameTypeDefaultDescription
contentStringrequired (.fixed)Hardcoded text.
dataHWDataTyperequired (default ctor)Field whose value is rendered.
styleHWTextStyle?nullFont, weight, color — see HWTextStyle.
textAlignHWTextAlign?nullMulti-line text alignment.

Exactly one of content (via .fixed) or data (via the default constructor) is supplied — the constructor you call enforces this.

Platform mapping

  • iOS: SwiftUI Text, with .multilineTextAlignment(...) when textAlign is set.
  • Android: Glance Text with a TextStyle.