Expandable List

Loading preview

Starting the Flutter app

ExpansionTile sections with child items

Get the source

Add it to your project

Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.

First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.

How it works

ListView.builder turns each entry of the const _sections list into an ExpansionTile whose children are ListTiles with a small dot icon. Expansion is handled entirely by ExpansionTile, so the page needs no state of its own. Item onTap handlers show a demo SnackBar.

Adapting it

  • Define a section class to replace the map, which removes the section['items'] as List<String> cast.
  • Add a route or callback per item and call it from onTap.
  • Set initiallyExpanded on the ExpansionTile if one section should open by default.