如何在抖动中显示警报内的列表视图

时间:2020-04-02 12:32:31

标签: android flutter cross-platform flutter-layout

我正在使用rflutter_alert插件通过Flutter处理我的应用程序中的警报 但是当我将listView用作参数内容时出现问题 其他小工具(例如文本)可以正常工作

我遇到以下错误

渲染库捕获异常Exception ═══════════ 在performLayout()期间引发了以下断言: RenderViewport不支持返回固有尺寸。

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();
          },
          );
        }),
  ),
)

这是插入网址 rflutter_alert

您能帮忙解决这个问题吗?

2 个答案:

答案 0 :(得分:0)

您可以尝试将其包装到容器中并设置宽度/高度

   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();

答案 1 :(得分:0)

您需要在shrinkWrap: true的“警告对话框”中添加一个ListView

像下面一样。

      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();
              },
            );
          }),