build method
Describes the part of the UI represented by this widget.
Implementation
@override
Widget build(BuildContext context) {
final theme = ThemeScope.of(context);
final titleStyle = _copyStyle(theme.bodyMedium)
..foreground(theme.onSurface)
..bold();
final chevronStyle = _copyStyle(theme.labelMedium)..foreground(theme.muted);
Widget header = Row(
gap: 1,
children: [
Text(expanded ? 'v' : '>', style: chevronStyle),
if (leading != null) leading!,
Text(title, style: titleStyle),
],
);
if (enabled && onChanged != null) {
header = GestureDetector(
onTap: () => onChanged?.call(!expanded),
child: header,
);
}
final content = Column(
gap: expanded ? 1 : 0,
children: [
header,
if (expanded)
Padding(
padding: padding ?? const EdgeInsets.only(left: 2),
child: child,
),
],
);
return content;
}