无法在 ExpansionTileCard 中嵌套列表
Not able to nest list in ExpansionTileCard in flutter
我正在尝试将 listview.builder
嵌套在 ExpansionTileCard
中,但无法这样做,我收到此错误
错误
The following assertion was thrown during performResize():
Vertical viewport was given unbounded height.
代码
ExpansionTileCard(
leading: GestureDetector(
onTap: (){
var firstdata = jsonResponse['content'];
code = firstdata[index]['code'];
},
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.asset('images/appicon.png', width: 50, height: 50)),
),
title: GestureDetector(
onTap: (){
var firstdata = jsonResponse['content'];
code = firstdata[index]['code'];
name = firstdata[index]['name'];
Navigator.push(context, MaterialPageRoute(builder: (context) =>PageViewClass(companycode: code,userid: widget.userid,)));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(firstdata[index]['name'] ?? 'NULL PASSED'),
],
),
),
children: <Widget>[
Divider(
thickness: 1.0,
height: 1.0,
),
Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0,
),
child:ListView.builder(
itemCount: list1.length,
itemBuilder: (BuildContext ctx, int index){
return Text(list1[index]['name']);
}
)
),
),
],
);
ExpansionTileCard
已在父 Listview.builder
中使用。
请指导我解决这个问题
在Listview.builder你可以尽量保持shrinkWrap: true
,
在 Column Widget 中,您可以保留 mainAxisSize = MainAxisSize.min
,
这两者的结合应该可以解决问题。
我正在尝试将 listview.builder
嵌套在 ExpansionTileCard
中,但无法这样做,我收到此错误
错误
The following assertion was thrown during performResize(): Vertical viewport was given unbounded height.
代码
ExpansionTileCard(
leading: GestureDetector(
onTap: (){
var firstdata = jsonResponse['content'];
code = firstdata[index]['code'];
},
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.asset('images/appicon.png', width: 50, height: 50)),
),
title: GestureDetector(
onTap: (){
var firstdata = jsonResponse['content'];
code = firstdata[index]['code'];
name = firstdata[index]['name'];
Navigator.push(context, MaterialPageRoute(builder: (context) =>PageViewClass(companycode: code,userid: widget.userid,)));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(firstdata[index]['name'] ?? 'NULL PASSED'),
],
),
),
children: <Widget>[
Divider(
thickness: 1.0,
height: 1.0,
),
Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0,
),
child:ListView.builder(
itemCount: list1.length,
itemBuilder: (BuildContext ctx, int index){
return Text(list1[index]['name']);
}
)
),
),
],
);
ExpansionTileCard
已在父 Listview.builder
中使用。
请指导我解决这个问题
在Listview.builder你可以尽量保持shrinkWrap: true
,
在 Column Widget 中,您可以保留 mainAxisSize = MainAxisSize.min
,
这两者的结合应该可以解决问题。