import 'package:flutter/material.dart'; /// The look every section title shares: a quiet, grouped-list label rather than /// another filled row. class SectionHeadingStyle { const SectionHeadingStyle({ required this.background, required this.body, required this.accent, required this.title, required this.line, }); final Color background; /// The page surface used behind pinned headings and section content. final Color body; final Color accent; final TextStyle title; final Color line; static SectionHeadingStyle of(BuildContext context) { final scheme = Theme.of(context).colorScheme; return SectionHeadingStyle( background: scheme.surface, body: scheme.surface, accent: scheme.primary, title: (Theme.of(context).textTheme.labelLarge ?? const TextStyle()) .copyWith( fontWeight: FontWeight.w600, letterSpacing: 0.4, color: scheme.onSurfaceVariant, ), line: scheme.outlineVariant, ); } } /// A section title strip: [title], then any [trailing] controls. class SectionHeading extends StatelessWidget { const SectionHeading({ super.key, required this.title, this.leading, this.trailing = const [], this.titleColor, this.padding = const EdgeInsetsDirectional.only(start: 12, end: 8), this.minHeight = 40, this.header = false, }); final String title; final Widget? leading; final List trailing; final Color? titleColor; final EdgeInsetsGeometry padding; final double minHeight; /// Announces the title as a heading to assistive tech (the trailing /// controls stay separate nodes). final bool header; @override Widget build(BuildContext context) { final style = SectionHeadingStyle.of(context); return ConstrainedBox( constraints: BoxConstraints(minHeight: minHeight), child: Padding( padding: padding, child: Row( children: [ if (leading != null) ...[leading!, const SizedBox(width: 8)], Expanded( child: Semantics( header: header, container: header, child: Text( title, maxLines: 1, overflow: TextOverflow.ellipsis, style: titleColor == null ? style.title : style.title.copyWith(color: titleColor), ), ), ), ...trailing, ], ), ), ); } }