dev
dart 53 lines 1.61 KB
Raw
1 import 'package:flutter/material.dart';
2
3 class StandardExpandableList<T> extends StatelessWidget {
4 StandardExpandableList({
5 required this.title,
6 required this.expandableItems,
7 this.decoration,
8 });
9
10 final String title;
11 final List<T> expandableItems;
12 final Decoration? decoration;
13
14 @override
15 Widget build(BuildContext context) {
16 return Container(
17 decoration: decoration ??
18 BoxDecoration(
19 color: Theme.of(context).colorScheme.surface,
20 ),
21 child: Theme(
22 data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
23 child: ExpansionTile(
24 iconColor: Theme.of(context).colorScheme.onSurface,
25 collapsedIconColor: Theme.of(context).colorScheme.onSurface,
26 title: Text(
27 title,
28 style: Theme.of(context).textTheme.bodyMedium!.copyWith(
29 fontWeight: FontWeight.w500,
30 ),
31 textAlign: TextAlign.left,
32 ),
33 children: expandableItems.map((item) {
34 return Padding(
35 padding: const EdgeInsets.only(left: 16.0, bottom: 8.0),
36 child: Align(
37 alignment: Alignment.centerLeft,
38 child: Text(
39 item.toString(),
40 maxLines: 1,
41 style: Theme.of(context).textTheme.bodyMedium!.copyWith(
42 fontSize: 16,
43 fontWeight: FontWeight.w500,
44 color: Theme.of(context).colorScheme.primary),
45 ),
46 ),
47 );
48 }).toList(),
49 ),
50 ),
51 );
52 }
53 }