ExpansionPanel (Flutter Widget of the Week)
Why Stack Overflow recommends it
Stack Overflow users link it when asking or answering how to build expandable, collapsible list items in Flutter and want a quick official demo of ExpansionPanel.
Recommended by 1 people across 1 different months, 2021 to 2022.
What it is
A 2 minute 11 second entry in the Flutter team's Widget of the Week series on the ExpansionPanel widget. It shows how to build a list of items that expand on tap to reveal more detail, with a linked DartPad example.
What people said
Recommends Bruno Kinast · 2021-08 · Stack Overflow · on “Create a DropDownMenu Item that dynamically adjusts widgets underneath”
I think what you are looking for is already a widget in Flutter. Take a look at ExpansionPanelList [LINK] or even ExpansionTile [LINK] . Here's a Flutter's Widget of the Week video about it: [this video]
Cites Faiizii Awan · 2021-06 · Stack Overflow · on “Flutter card layout and design”
You can use ExpansionPanel [this video] to achieve your results List<bool> isExpanded = []; //the size/length should be equal to the size of your data list ExpansionPanelList(children: [ //generate the panels from your data list ExpansionPanel( headerBuilder: (context, isExpanded) { return _headerHere(); }, body: _bodyHere(), isExpanded: isExpanded[0], //index of your card canTapOnHeader: true,// to make the complete header clickable ) ], expansionCallback: (panelIndex, expanded) { setState(() { isExpanded[panelIndex] = !expanded; }); }, ),
Cites shawnblais · 2022-03 · Stack Overflow · on “Flutter widget to grow and shrink according to child size?”
Is there a widget, or a simple way, to have a container that animates it's size, in response to its child? So something like this might animate smoothly between open and closed builders ResizingBox( openBuilder: (_) => FlutterLogo(size: 200), closedBuilder: (_) => FlutterLogo(size: 50), ), Essentially looking for the expanding/contracting behavior of ExpandingPanel but, inside of a Stack, and expanding both Vt and Hz: [this video]
Cites CraigFoote · 2022-12 · Stack Overflow · on “RangeError when trying to get flutter ExpansionPanel to expand”
I saw the Widget of the Week at [this video] and copied the code to a State class that I cannot get to work. class SearchResultsPageState extends State<SearchResultsPage> { final List<bool> _isOpen = []; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("test"), ), body: SingleChildScrollView( child: ExpansionPanelList( children: [ ExpansionPanel( headerBuilder: (context, isExpanded) => const Text('one'), body: const Text('one one\none'), isExpanded: _isOpen.isNotEmpty ? _isOpen[0] : false, ), ExpansionPanel( headerBuilder: (context, isExpanded) => const Text('two'), body: const Text('two two\ntwo'), isExpanded: _isOpen.isNotEmpty ? _isOpen[1] : fal