Skip to content

Instantly share code, notes, and snippets.

@diamantidis
Created October 10, 2021 14:50
Show Gist options
  • Save diamantidis/cd9b809019146f8d9ee102c7e3f63230 to your computer and use it in GitHub Desktop.
Save diamantidis/cd9b809019146f8d9ee102c7e3f63230 to your computer and use it in GitHub Desktop.
class TableOfContents extends StatelessWidget {
final List<Section> sections;
final void Function(Section) onItemTap;
const TableOfContents({
Key? key,
this.sections = const <Section>[],
required this.onItemTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.all(20),
padding: const EdgeInsets.only(left: 16, top: 24, right: 16, bottom: 10),
decoration: BoxDecoration(
color: Colors.white12.withOpacity(0.3),
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
border: Border.all(
width: 2,
color: Colors.grey,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: sections
.map((e) => SectionLink(section: e, onTap: onItemTap))
.toList(),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment