如何在 flutter 中显示 listview inside alert
how to display listview inside alert in flutter
我正在使用 rflutter_alert 插件来处理我使用 Flutter 的应用程序中的警报
但是当我将 listView 用于参数内容时出现问题
文本等其他小部件可以正常工作
我收到以下错误
Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderViewport does not support returning intrinsic dimensions.
Expanded(
child: Card(
child: ListView.builder(
itemCount: content.length,
itemBuilder: (ctx, index) {
return ListTile(title: Text(content[index]["doctor_name"]),
onTap: (){
Alert(
context: context,
title: doctors[index]["doctor_name"],
content: ListView(children: <Widget>[
Text(doctors[index]["major"]),
Text(doctors[index]["hospital"]),
],)
).show();
},
);
}),
),
)
这是布线 url
rflutter_alert
你能帮忙解决这个问题吗?
您可以尝试将其包装到容器中并设置 width/height
onTap: (){
Alert(
context: context,
title: doctors[index]["doctor_name"],
content: Container(
width: 100,
height: 100,
child: ListView(children: <Widget>[
Text(doctors[index]["major"]),
Text(doctors[index]["hospital"]),
],))
).show();
您需要在 ListView
的警报对话框中添加一个 shrinkWrap: true
。
如下所示。
ListView.builder(
itemCount: 10,
itemBuilder: (ctx, index) {
return ListTile(
title: Text('$index'),
onTap: () {
Alert(
context: context,
title: 'Title',
content: ListView(
shrinkWrap: true, // Like here
children: <Widget>[
Text('Test'),
Text('Test'),
],
),
).show();
},
);
}),
我正在使用 rflutter_alert 插件来处理我使用 Flutter 的应用程序中的警报 但是当我将 listView 用于参数内容时出现问题 文本等其他小部件可以正常工作
我收到以下错误
Exception caught by rendering library ═════════════════════════════════════════════════════ The following assertion was thrown during performLayout(): RenderViewport does not support returning intrinsic dimensions.
Expanded(
child: Card(
child: ListView.builder(
itemCount: content.length,
itemBuilder: (ctx, index) {
return ListTile(title: Text(content[index]["doctor_name"]),
onTap: (){
Alert(
context: context,
title: doctors[index]["doctor_name"],
content: ListView(children: <Widget>[
Text(doctors[index]["major"]),
Text(doctors[index]["hospital"]),
],)
).show();
},
);
}),
),
)
这是布线 url rflutter_alert
你能帮忙解决这个问题吗?
您可以尝试将其包装到容器中并设置 width/height
onTap: (){
Alert(
context: context,
title: doctors[index]["doctor_name"],
content: Container(
width: 100,
height: 100,
child: ListView(children: <Widget>[
Text(doctors[index]["major"]),
Text(doctors[index]["hospital"]),
],))
).show();
您需要在 ListView
的警报对话框中添加一个 shrinkWrap: true
。
如下所示。
ListView.builder(
itemCount: 10,
itemBuilder: (ctx, index) {
return ListTile(
title: Text('$index'),
onTap: () {
Alert(
context: context,
title: 'Title',
content: ListView(
shrinkWrap: true, // Like here
children: <Widget>[
Text('Test'),
Text('Test'),
],
),
).show();
},
);
}),