首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Divider之后添加网格视图?

如何在Divider之后添加网格视图?
EN

Stack Overflow用户
提问于 2022-10-03 16:13:43
回答 1查看 55关注 0票数 0

这是我的代码,我运行了代码,但没有输出显示

代码语言:javascript
复制
 Divider(thickness: 5),
            Padding(
              padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 5),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    "Best Destination",
                    style: TextStyle(color: Colors.teal, fontSize: 20),
                  ),
                  Text("SEE ALL")
                ],
              ),
            ),
            GridView(
              gridDelegate:
                  SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
              children: [
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
              ],
            ),
EN

回答 1

Stack Overflow用户

发布于 2022-10-03 18:55:22

当顶层小部件为GridView时,尝试用Expanded包装Column

代码语言:javascript
复制
class GriVIssue extends StatelessWidget {
  const GriVIssue({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Divider(thickness: 5),
          Padding(
            padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 5),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  "Best Destination",
                  style: TextStyle(color: Colors.teal, fontSize: 20),
                ),
                Text("SEE ALL")
              ],
            ),
          ),
          Expanded(
            child: GridView(
              gridDelegate:
                  SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
              children: [
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
                Container(
                  color: Colors.blue,
                  margin: EdgeInsets.all(5),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

查看有关此无界高度/宽度解码颤振的更多信息

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73938109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档