Flutter ListView.builder在警报对话框中不工作



我想在警报对话框中显示项目列表,以进行付款确认。但它不起作用,我尝试了很多解决方案。

AlertDialog(
titlePadding: EdgeInsets.all(0),
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
title: Text("Heading"),
content: ListView.builder(
shrinkWrap: true,
itemCount: items.length,
itemBuilder: (ctx, i) {
return getRowWidget(i);
}),
);

这将解决您的问题,添加带宽度的Container

showDialog(
context: context,
builder: (context) => AlertDialog(
titlePadding: EdgeInsets.all(0),
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
title: Text("Heading"),
content: Container(
width: double.maxFinite,
child: ListView.builder(
shrinkWrap: true,
itemCount: items.length,
itemBuilder: (ctx, i) {
return Text(items[i].toString());
}),
),
),
);

使用此代码。

showDialog(
context: context,
builder: (context) => AlertDialog(
titlePadding: EdgeInsets.all(0),
contentPadding:
EdgeInsets.symmetric(horizontal: 10, vertical: 0),
title: Text("Heading"),
content: Container(
height: 100,
child: ListView.builder(
shrinkWrap: true,
itemCount: 1,
itemBuilder: (ctx, i) {
return Text("text");
}),
),
),
);

相关内容

  • 没有找到相关文章

最新更新