Flutter ListView内部的扩展文件-页面不滚动
我面临页面滚动的问题。我每天向用户显示分组的事务。 因此,ExpansionFile中会有多个项 我首先从数据库中提取天数,然后提取当天完成的事务。 下面是我的页面是如何工作的Flutter ListView内部的扩展文件-页面不滚动,flutter,dart,flutter-listview,Flutter,Dart,Flutter Listview,我面临页面滚动的问题。我每天向用户显示分组的事务。 因此,ExpansionFile中会有多个项 我首先从数据库中提取天数,然后提取当天完成的事务。 下面是我的页面是如何工作的 记录 获取天数并放入一个列表(天数列表) 在此列表中加载带有for循环的主扩展磁贴(天数列表) 当我们执行for循环时,在当天获取事务并加载到另一个数组中 将子列表作为子项绑定到ExpansionFile 我的视图正在正确加载,但当我打开ExpansionFile的子项时,我无法滚动页面。请查看视频以获得更清晰的理解。
Widget build(BuildContext context) {
return new Scaffold(
body: FutureBuilder(
future: getTransactions(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
} else if (feedItemsParent.isEmpty) {
return noRecordsDialogue(context, 'No transactions record', '');
} else if (feedItemsParent.length == 0) {
return noRecordsDialogue(context, 'No transactions record', '');
} else {
return new ListView.builder(
shrinkWrap: true,
itemCount: feedItemsParent.length,
itemBuilder: (BuildContext ctxt, int index) =>
buildBody(ctxt, index));
}
},
),
);
}
下面是buildBody函数
Widget buildBody(BuildContext ctxt, int index) {
return new custom.ExpansionTile(
initiallyExpanded: true,
trailing: new Container(width: 20),
headerBackgroundColor: Color(0xFFeff0f1),
title: Text(
feedItemsParent[index].transactiondatesmall.toString(),
style: TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
children: <Widget>[
buildTransactionList(
feedItemsParent[index].transactiondatesmall.toString()),
],
);
}
Widget buildBody(BuildContext-ctxt,int-index){
返回新的custom.ExpansionFile(
初始扩展:正确,
尾随:新容器(宽度:20),
headerBackgroundColor:颜色(0xFFEF0F1),
标题:正文(
feedItemsParent[index].transactiondatesmall.toString(),
样式:TextStyle(
尺寸:16,
颜色:颜色,黑色,
fontWeight:fontWeight.bold,
),
),
儿童:[
buildTransactionList(
feedItemsParent[index].transactiondatesmall.toString()),
],
);
}
下面是我如何将所有子项绑定到ExpansionFile中的
buildTransactionList(dtCompare) {
if (feedItems.length == 0) {
return noRecordsDialogue(context, 'No transactions record', '');
} else {
List<UserTransaction> feedItemsChild = [];
for (int j = 0; j < feedItems.length; j++) {
if (feedItems[j].transactiondatesmall == dtCompare) {
feedItemsChild.add(feedItems[j]);
}
}
return ListView(
padding: const EdgeInsets.only(bottom: 16.0),
shrinkWrap: true,
children: feedItemsChild,
);
}
}
buildTransactionList(dtCompare){
如果(feedItems.length==0){
返回noRecordsDialogue(上下文“无交易记录”和“”);
}否则{
列表feedItemsChild=[];
对于(int j=0;j
提前感谢。最后,我可以使用下面链接中给出的答案来解决这个问题。根据回答中给出的更改了我的代码,因为我的要求80%相似 多谢各位