【问题标题】:Flutter - GridView/ListView.builder with row with containers taking same height of large containerFlutter - GridView/ListView.builder,其中容器的行与大容器的高度相同
【发布时间】:2021-11-11 11:55:31
【问题描述】:

我正在尝试设计以下内容的垂直可滚动视图,目前我正在使用 GridView 和 0.7 的 childAspectRation 来执行此操作,但这不起作用,因为某些文本可能会占用更多高度(要隐藏的文本)或较小的高度(太多的空白)。但是,我希望每个单独的网格视图都采用最大的 GridView 中的最高值。例如。标题 A = 100 高度动态计算,其余小于 100 高度,则所有网格视图应采用高度 100。

我也知道列和行与固有高度的组合,但我无法完成它,因为固有高度基于每一行而不是所有行。

谢谢!

【问题讨论】:

  • 您尝试过使用 Wrap 吗?然后在包装里面是你的卡片,它基于文本多长或多短,你也可以让它更灵活。
  • @ArbiterChil 你能建议如何做到这一点吗?我尝试过使用它,但我对此不是很熟悉并且无法实现我所需要的

标签: flutter flutter-layout flutter-web


【解决方案1】:

这是它的一个示例。

final listofYourModel = [
     YouModeldata(
      title:"title",
      description: "Longtexttttttttttt"),
      YouModeldata(
      title:"title",
      description: "Longtexttttttttttt"),
     ];

     Container(
        width: MediaQuery.of(context).size.width,
        child:  Wrap(
         alignment: WrapAlignment.start,
         spacing: 10,
         runSpacing: 10
         children: listofYourModel.map((e)
         //Your Card Widget
         YourCardWidget(
          title: e.title,
          description: e.description
          ),
         ).toList()
        ),
       )

如果这个不能滚动,则将这个包裹到 SingleSchildScrollview

【讨论】:

  • @Tan Boon Jun 我更新了我的答案
猜你喜欢
  • 2018-12-07
  • 1970-01-01
  • 2020-07-07
  • 2022-12-18
  • 2020-06-20
  • 2021-05-25
  • 2013-12-28
  • 2021-06-21
相关资源
最近更新 更多