build method
Builds the CardSection widget, applying responsive layout and theme integrations.
Uses MediaQuery to determine screen width and conditionally renders leading/trailing via Basic widget.
Wraps content in Pylon with OverrideEdgeInsets for custom padding, then GlowCard for elevated appearance.
The body is a Column with header Row, optional Gap, Divider, and children. Integrates ArcaneTheme
for colors, borders, and elevation. Efficiently handles empty children to avoid unnecessary Divider rendering.
Supports performance by using const widgets where possible and avoiding deep rebuilds in lists.
Implementation
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Pylon<OverrideEdgeInsets>(
value: OverrideEdgeInsets(
const EdgeInsets.symmetric(vertical: 8, horizontal: 0)),
builder: (context) => Card(
dashedBorder: dashedBorder,
thumbHash: thumbHash,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Basic(
leading: width > leadingThreshold || essentialLeading
? (leading ??
(leadingIcon != null
? FancyIcon(icon: leadingIcon!)
: null))
: null,
trailing: width > trailingThreshold || essentialTrailing
? trailing
: null,
title: title ?? (titleText != null ? Text(titleText!) : null),
subtitle: subtitle ??
(subtitleText != null ? Text(subtitleText!) : null),
))
],
),
if (children.isNotEmpty) ...[
Gap(16),
Divider(),
Gap(8),
...children
]
],
),
),
);
}