I'm trying to generate a list of ExpansionTiles that has another list of ExpansionTiles as children. The lists are generated by receiving data from the database. The problem is that when I click on an ExpansionTile it gives me this error and it doesn't expand:
The following assertion was thrown during performResize(): Vertical viewport was given unbounded height. Viewports expand in the scrolling direction to fill their container. In this case, a vertical viewport was given an unlimited amount of vertical space in which to expand. This situation typically happens when a scrollable widget is nested inside another scrollable widget.
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Center(child: Text('MAGAZZINO',
style: TextStyle(fontWeight: FontWeight.bold))),
),
body: _error != ""
? Center(child: Text('Error: $_error'),)
: ListView.builder(
controller: _scrollController,
itemCount: _list.length + (_isLoading ? 1 : 0),
itemBuilder: (BuildContext context, int i) {
if (i == _list.length) {
return const Center(child: CircularProgressIndicator());
} else {
return Container(
child: ExpansionTile(
leading: CircleAvatar(child: Text("${_list[i].sommaCodici()}")),
title: Text("BANCALE: ${_list[i].getBancale()}"),
subtitle: Text("data creazione: ${_list[i].getData()}"),
children: <Widget>[
ListView.builder(
itemCount: _list[i].sommaCodici(),
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int j){
child: Card(
child: ExpansionTile(
onExpansionChanged: (bool change) {
},
leading: CircleAvatar(child: Text("${_list[i].getnPezziC()[j]}")),
title: Text("codice: ${_list[i].getCodiciC()[j]}"),
subtitle: Text("data: ${_list[i].getDateC()[j]}"),
children: <Widget>[
Expanded(
child: ButtonBar(
alignment: MainAxisAlignment.spaceAround,
buttonHeight: 52.0,
buttonMinWidth: 90.0,
children: <Widget>[
Expanded(
child: TextButton(
style: flatButtonStyle,
onPressed: () {
VaiImpegna(DMag(_list[i].getCodiciC()[j], _list[i].getBancale(),
_list[i].getnPezziC()[j], _list[i].getDateC()[j]));
},
child: const Column(
children: <Widget>[
Icon(Icons.arrow_downward),
Padding(
padding: EdgeInsets.symmetric(vertical: 2.0),
),
Text('Impegna'),
],
),
),
),
Expanded(
child: TextButton(
style: flatButtonStyle,
onPressed: () {
VaiResi(DMag(_list[i].getCodiciC()[j], _list[i].getBancale(),
_list[i].getnPezziC()[j], _list[i].getDateC()[j]));
},
child: const Column(
children: <Widget>[
Icon(Icons.arrow_upward),
Padding(
padding: EdgeInsets.symmetric(vertical: 2.0),
),
Text('Reso'),
],
),
),
),
Expanded(
child: TextButton(
style: flatButtonStyle,
onPressed: () {
},
child: const Column(
children: <Widget>[
Icon(Icons.swap_vert),
Padding(
padding: EdgeInsets.symmetric(vertical: 2.0),
),
Text('Elimina'),
],
),
),
),
],
),
),
],
),
);
}
),
],
),
);
}
},
),
);
}
I try to add expanded widgets but didn't worked. the only thing that worked was using a Container and giving it an accurate height. But it can't be a valid solution since I can't know how long the list could be.