buildTitle function
Implementation
Widget buildTitle(BuildContext context, OpenUiNode node) {
final theme = node.theme;
final name = node.props.string('size');
final slot = BlockSlot.of(context, node.element);
final base = _titleMetrics(
theme,
name,
compact: MediaQuery.sizeOf(context).width <= 640,
);
final cardTitle =
(name == null || name == 'sm' || name == 'md') &&
_isCardTitle(context, slot);
final cardSized =
(name == 'lg' || name == 'xl' || name == '2xl' || name == '3xl') &&
_isCardSized(slot);
final (fontSize, height, letterSpacing, weight) = cardTitle
? (
theme.fontSizeOf('Title.card', 14),
20 / 14,
base.letterSpacing,
theme.typography.medium,
)
: cardSized
? (
theme.fontSizeOf('Title.cardLarge', 18),
24 / 18,
-0.3,
theme.typography.semibold,
)
: (
base.fontSize,
base.height,
base.letterSpacing,
theme.typography.semibold,
);
final style = _textStyle(
theme,
color: theme.fg(node.props['color']) ?? theme.ink,
size: fontSize,
height: height,
letterSpacing: letterSpacing,
weight: weight,
fontFeatures: theme.typography.tabular,
);
return Semantics(
header: true,
headingLevel: _headingLevels[name ?? 'md'] ?? 3,
child: _richText(context, node, node.props.string('text') ?? '', style),
);
}