A RenderFlex 在右侧溢出了 150 像素

时间:2021-05-26 14:16:59

标签: flutter

我不知道我在这里做错了什么,但总是向右溢出 150 像素,即使我用 Expanded 包裹我的卡片,Flexible 也有同样的问题

asyncorganization.when(
            data: (org) => Scaffold(
                  body: Column(
                    children: <Widget>[
                      Expanded(
                        flex: 1,
                        child: GridView(
                          gridDelegate:
                              SliverGridDelegateWithFixedCrossAxisCount(
                                  crossAxisCount: 2),
                          children: org.activities
                              .map((e) => Padding(
                                    padding: const EdgeInsets.all(6.0),
                                    child: Card(
                                      child: ListTile(
                                        title: TextButton.icon(
                                            onPressed: null,
                                            icon: Icon(Icons.volunteer_activism),
                                            label: Text("${e.title}")),
                                        subtitle: CircleAvatar(
                                          backgroundImage: NetworkImage("${e.picture}"),
                                          radius: 20,
                                          backgroundColor: Colors.transparent,
                                        ),
                                      ),
                                    ),
                                  ))
                              .toList(),
                        ),
                      )
                    ],
                  ),
                ),
            loading: () => const CircularProgressIndicator(),
            error: (error, stack) => Center(
                  child: Text("$error"),
                ))

1 个答案:

答案 0 :(得分:0)

尝试为 TextButton 的标签设置 Flexible

ListTile(
                      title: TextButton.icon(
                          onPressed: null,
                          icon: Icon(Icons.volunteer_activism),
                          label: Flexible(child: Text("test"))),
                      subtitle: CircleAvatar(
                        backgroundImage: NetworkImage(""),
                        radius: 20,
                        backgroundColor: Colors.transparent,
                      ),
                    )