main
1import 'package:flutter/material.dart';
2
3/// A [Column] with a leading title.
4class TitledColumn extends StatelessWidget {
5 /// Create a [Column] with a leading title.
6 ///
7 /// Useful for labeling lists and singular widgets.
8 ///
9 /// Internally this is a column with a title list tile before the children
10 const TitledColumn({super.key,
11 required this.title,
12 required this.children,
13 });
14
15 /// Title to display above the [children].
16 ///
17 /// Usually a [Text] widget.
18 final Widget title;
19
20 /// Items that get listed.
21 final List<Widget> children;
22
23 @override
24 Widget build(BuildContext context) {
25 final List<Widget> items = [
26 ListTile(
27 title: DefaultTextStyle(
28 style: Theme.of(context).textTheme.titleLarge!,
29 child: title,
30 ),
31 ),
32 ];
33 items.addAll(children);
34 return Column(
35 children: items,
36 );
37 }
38}