buildCard function
Implementation
Widget buildCard(BuildContext context, OpenUiNode node) {
final theme = node.theme;
final nested = context.findAncestorWidgetOfExactType<_CardScope>() != null;
final compact = nested || MediaQuery.sizeOf(context).width <= 640;
final soft = node.props.string('variant') == 'soft';
final s = theme.styleOf('Card', soft ? 'soft' : 'outline');
final gap = theme.spaceOf(node.props['gap']);
final body = _column(
context,
_slot(
_items(node, node.props['children']),
parent: SlotParent.card,
flow: gap == null,
),
gap: gap,
cross: CrossAxisAlignment.stretch,
flowBase: 12,
);
final modelPadding = theme.spaceOf(node.props['padding']);
Widget content = _CardScope(
child: DefaultTextStyle.merge(
style: TextStyle(fontSize: theme.fontSizeOf('Card', 14), height: 1.55),
child: CardHeadScope(active: false, child: body),
),
);
if (s.foreground case final foreground?) {
content = OpenUiThemeScope(
theme: theme.withInk(foreground),
child: DefaultTextStyle.merge(
style: TextStyle(color: foreground),
child: content,
),
);
}
return Container(
padding: modelPadding != null
? EdgeInsets.all(modelPadding)
: s.padding ?? EdgeInsets.all(compact ? 16 : 20),
decoration: BoxDecoration(
color: s.background ?? (soft ? theme.surface : theme.canvas),
borderRadius: BorderRadius.circular(
s.radius ?? (nested ? theme.radii.lg : theme.radii.xl),
),
border: Border.all(
color: s.border ?? (soft ? Colors.transparent : theme.border),
),
),
child: content,
);
}